mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
The magnet ring now only uses RF when actually sucking items.
Makes more sense, does it not?
This commit is contained in:
parent
fa79e57cb6
commit
493be37ede
1 changed files with 19 additions and 18 deletions
|
@ -36,13 +36,14 @@ 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<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()){
|
||||
for(EntityItem item : items){
|
||||
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){
|
||||
|
@ -54,16 +55,16 @@ public class ItemMagnetRing extends ItemEnergy{
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Use Energy per tick
|
||||
if(!((EntityPlayer)entity).capabilities.isCreativeMode){
|
||||
this.extractEnergy(stack, energyUse, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
|
|
Loading…
Reference in a new issue