mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +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,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<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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue