mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Redo the ring a bit so that it now pulls items upwards
This commit is contained in:
parent
2ce27f4735
commit
0a5c306f30
1 changed files with 21 additions and 11 deletions
|
@ -38,21 +38,31 @@ public class ItemMagnetRing extends ItemEnergy{
|
||||||
if(!items.isEmpty()){
|
if(!items.isEmpty()){
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
if(this.getEnergyStored(stack) >= energyUse){
|
if(this.getEnergyStored(stack) >= energyUse){
|
||||||
//If the Item is near enough to get picked up
|
double x = entity.posX+0.5D-item.posX;
|
||||||
//(So it doesn't bounce around until it notices itself..)
|
double y = entity.posY+1D-item.posY;
|
||||||
if(new Vec3d(entity.posX, entity.posY, entity.posZ).distanceTo(new Vec3d(item.posX, item.posY, item.posZ)) <= 1.5){
|
double z = entity.posZ+0.5D-item.posZ;
|
||||||
item.onCollideWithPlayer((EntityPlayer)entity);
|
|
||||||
|
double distance = x*x+y*y+z*z;
|
||||||
|
if(distance <= 1.5){
|
||||||
|
if(entity instanceof EntityPlayer){
|
||||||
|
item.onCollideWithPlayer((EntityPlayer)entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
double speed = 0.02;
|
double speed = 0.035/distance;
|
||||||
//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){
|
item.motionX += x*speed;
|
||||||
this.extractEnergy(stack, energyUse, false);
|
if(y >= 0){
|
||||||
|
item.motionY = 0.125;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
item.motionY += y*speed;
|
||||||
|
}
|
||||||
|
item.motionZ += z*speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(entity instanceof EntityPlayer) || !((EntityPlayer)entity).capabilities.isCreativeMode){
|
||||||
|
this.extractEnergy(stack, energyUse, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
Loading…
Reference in a new issue