diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java index 16b307089..af77c09ef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java @@ -36,32 +36,33 @@ public class ItemMagnetRing extends ItemEnergy{ @SuppressWarnings("unchecked") @Override public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ - int energyUse = 5; - if(this.getEnergyStored(stack) >= energyUse && !entity.isSneaking()){ + int energyUse = 20; + if(!entity.isSneaking()){ //Get all the Items in the area int range = 5; ArrayList items = (ArrayList)world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX-range, entity.posY-range, entity.posZ-range, entity.posX+range, entity.posY+range, entity.posZ+range)); if(!items.isEmpty()){ for(EntityItem item : items){ - //If the Item is near enough to get picked up - //(So it doesn't bounce around until it notices itself..) - if(Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ).distanceTo(Vec3.createVectorHelper(item.posX, item.posY, item.posZ)) <= 1.5){ - item.onCollideWithPlayer((EntityPlayer)entity); - } - else{ - double speed = 0.02; - //Move the Item closer to the Player - item.motionX += (entity.posX+0.5-item.posX)*speed; - item.motionY += (entity.posY+1.0-item.posY)*speed; - item.motionZ += (entity.posZ+0.5-item.posZ)*speed; + if(this.getEnergyStored(stack) >= energyUse){ + //If the Item is near enough to get picked up + //(So it doesn't bounce around until it notices itself..) + if(Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ).distanceTo(Vec3.createVectorHelper(item.posX, item.posY, item.posZ)) <= 1.5){ + item.onCollideWithPlayer((EntityPlayer)entity); + } + else{ + double speed = 0.02; + //Move the Item closer to the Player + item.motionX += (entity.posX+0.5-item.posX)*speed; + item.motionY += (entity.posY+1.0-item.posY)*speed; + item.motionZ += (entity.posZ+0.5-item.posZ)*speed; + + if(!((EntityPlayer)entity).capabilities.isCreativeMode){ + this.extractEnergy(stack, energyUse, false); + } + } } } } - - //Use Energy per tick - if(!((EntityPlayer)entity).capabilities.isCreativeMode){ - this.extractEnergy(stack, energyUse, false); - } } }