The magnet ring now only uses RF when actually sucking items.

Makes more sense, does it not?
This commit is contained in:
Ellpeck 2016-01-07 15:54:41 +01:00
parent fa79e57cb6
commit 493be37ede

View file

@ -36,32 +36,33 @@ public class ItemMagnetRing extends ItemEnergy{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
int energyUse = 5; int energyUse = 20;
if(this.getEnergyStored(stack) >= energyUse && !entity.isSneaking()){ if(!entity.isSneaking()){
//Get all the Items in the area //Get all the Items in the area
int range = 5; int range = 5;
ArrayList<EntityItem> items = (ArrayList<EntityItem>)world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX-range, entity.posY-range, entity.posZ-range, entity.posX+range, entity.posY+range, entity.posZ+range)); ArrayList<EntityItem> items = (ArrayList<EntityItem>)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()){ if(!items.isEmpty()){
for(EntityItem item : items){ for(EntityItem item : items){
//If the Item is near enough to get picked up if(this.getEnergyStored(stack) >= energyUse){
//(So it doesn't bounce around until it notices itself..) //If the Item is near enough to get picked up
if(Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ).distanceTo(Vec3.createVectorHelper(item.posX, item.posY, item.posZ)) <= 1.5){ //(So it doesn't bounce around until it notices itself..)
item.onCollideWithPlayer((EntityPlayer)entity); 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; else{
//Move the Item closer to the Player double speed = 0.02;
item.motionX += (entity.posX+0.5-item.posX)*speed; //Move the Item closer to the Player
item.motionY += (entity.posY+1.0-item.posY)*speed; item.motionX += (entity.posX+0.5-item.posX)*speed;
item.motionZ += (entity.posZ+0.5-item.posZ)*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);
}
} }
} }