Attempt at fixing rough NSWE movement

This commit is contained in:
Aidan Brady 2013-08-03 02:23:07 -04:00
parent 011695b875
commit d12cf1070f
2 changed files with 130 additions and 51 deletions

View file

@ -0,0 +1,58 @@
package resonantinduction.contractor;
import java.lang.reflect.Method;
import java.util.Iterator;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.item.ItemExpireEvent;
/**
* Spinoff of EntityItem for Contractors.
* @author AidanBrady
*
*/
public class EntityContractorItem extends EntityItem
{
public boolean doGravityThisTick = true;
public EntityContractorItem(World par1World)
{
super(par1World);
}
@Override
public void onUpdate()
{
super.onUpdate();
if(!doGravityThisTick)
{
motionY = 0;
}
}
public static EntityContractorItem get(EntityItem entityItem)
{
EntityContractorItem item = new EntityContractorItem(entityItem.worldObj);
item.posX = entityItem.posX;
item.posY = entityItem.posY;
item.posZ = entityItem.posZ;
item.setEntityItemStack(entityItem.getEntityItem());
item.motionX = entityItem.motionX;
item.motionY = entityItem.motionY;
item.motionZ = entityItem.motionZ;
item.dataWatcher = entityItem.getDataWatcher();
return item;
}
}

View file

@ -37,6 +37,18 @@ public class TileEntityEMContractor extends TileEntity
{ {
EntityItem entityItem = (EntityItem)entity; EntityItem entityItem = (EntityItem)entity;
if(!(entityItem instanceof EntityContractorItem))
{
entityItem.setDead();
EntityContractorItem newItem = EntityContractorItem.get(entityItem);
worldObj.spawnEntityInWorld(newItem);
entityItem = newItem;
}
if(entityItem instanceof EntityContractorItem)
{
switch(facing) switch(facing)
{ {
case DOWN: case DOWN:
@ -60,6 +72,8 @@ public class TileEntityEMContractor extends TileEntity
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case NORTH: case NORTH:
((EntityContractorItem)entityItem).doGravityThisTick = false;
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5); entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5);
entityItem.motionY = 0; entityItem.motionY = 0;
@ -70,6 +84,8 @@ public class TileEntityEMContractor extends TileEntity
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case SOUTH: case SOUTH:
((EntityContractorItem)entityItem).doGravityThisTick = false;
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5); entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5);
entityItem.motionY = 0; entityItem.motionY = 0;
@ -80,6 +96,8 @@ public class TileEntityEMContractor extends TileEntity
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case WEST: case WEST:
((EntityContractorItem)entityItem).doGravityThisTick = false;
entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ); entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ);
entityItem.motionX = 0; entityItem.motionX = 0;
@ -90,6 +108,8 @@ public class TileEntityEMContractor extends TileEntity
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case EAST: case EAST:
((EntityContractorItem)entityItem).doGravityThisTick = false;
entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ); entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ);
entityItem.motionX = 0; entityItem.motionX = 0;
@ -104,6 +124,7 @@ public class TileEntityEMContractor extends TileEntity
} }
} }
} }
}
public void updateBounds() public void updateBounds()
{ {