Adjustments
This commit is contained in:
parent
236e80bfe1
commit
8278bb7794
3 changed files with 68 additions and 92 deletions
|
@ -31,41 +31,10 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
|
|||
return BlockRenderingHandler.INSTANCE.getRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack)
|
||||
{
|
||||
TileEntityEMContractor tileEntity = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z);
|
||||
int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int height = Math.round(entityliving.rotationPitch);
|
||||
|
||||
int change = 1;
|
||||
|
||||
if(height >= 65)
|
||||
{
|
||||
change = 1;
|
||||
}
|
||||
else if(height <= -65)
|
||||
{
|
||||
change = 0;
|
||||
}
|
||||
else {
|
||||
switch(side)
|
||||
{
|
||||
case 0: change = 2; break;
|
||||
case 1: change = 5; break;
|
||||
case 2: change = 3; break;
|
||||
case 3: change = 4; break;
|
||||
}
|
||||
}
|
||||
|
||||
tileEntity.setFacing(ForgeDirection.getOrientation(change));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z);
|
||||
tileContractor.updateBounds();
|
||||
|
||||
if(!tileContractor.isLatched())
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class ItemBlockContractor extends ItemBlock
|
||||
{
|
||||
|
@ -20,6 +21,7 @@ public class ItemBlockContractor extends ItemBlock
|
|||
if(place)
|
||||
{
|
||||
TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z);
|
||||
tileContractor.setFacing(ForgeDirection.getOrientation(side));
|
||||
}
|
||||
|
||||
return place;
|
||||
|
|
|
@ -30,6 +30,7 @@ public class TileEntityEMContractor extends TileEntity
|
|||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
System.out.println(facing + " " + worldObj.isRemote);
|
||||
pushDelay = Math.max(0, pushDelay--);
|
||||
|
||||
if(!suck && pushDelay == 0)
|
||||
|
@ -40,6 +41,11 @@ public class TileEntityEMContractor extends TileEntity
|
|||
if(operationBounds != null)
|
||||
{
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, operationBounds);
|
||||
|
||||
if(!list.isEmpty())
|
||||
{
|
||||
System.out.println("GOood");
|
||||
}
|
||||
|
||||
for(Entity entity : list)
|
||||
{
|
||||
|
@ -88,63 +94,6 @@ public class TileEntityEMContractor extends TileEntity
|
|||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
case NORTH:
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5);
|
||||
}
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION);
|
||||
}
|
||||
|
||||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
case SOUTH:
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5);
|
||||
}
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION);
|
||||
}
|
||||
|
||||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
case WEST:
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ);
|
||||
}
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ-ACCELERATION);
|
||||
}
|
||||
|
||||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
case EAST:
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ);
|
||||
|
@ -161,6 +110,63 @@ public class TileEntityEMContractor extends TileEntity
|
|||
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION);
|
||||
}
|
||||
|
||||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
case SOUTH:
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ);
|
||||
}
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ-ACCELERATION);
|
||||
}
|
||||
|
||||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
case WEST:
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5);
|
||||
}
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION);
|
||||
}
|
||||
|
||||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
case EAST:
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5);
|
||||
}
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION);
|
||||
}
|
||||
|
||||
entityItem.isAirBorne = true;
|
||||
break;
|
||||
}
|
||||
|
@ -180,7 +186,7 @@ public class TileEntityEMContractor extends TileEntity
|
|||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, Math.min(yCoord+MAX_REACH, 255), zCoord+1);
|
||||
break;
|
||||
case NORTH:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+MAX_REACH, yCoord+1, zCoord+1);
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord-MAX_REACH, xCoord+1, yCoord+1, zCoord);
|
||||
break;
|
||||
case SOUTH:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord-MAX_REACH, yCoord, zCoord, xCoord, yCoord+1, zCoord+1);
|
||||
|
@ -189,7 +195,7 @@ public class TileEntityEMContractor extends TileEntity
|
|||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+1, zCoord+MAX_REACH);
|
||||
break;
|
||||
case EAST:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord-MAX_REACH, xCoord+1, yCoord+1, zCoord);
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+MAX_REACH, yCoord+1, zCoord+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -212,8 +218,6 @@ public class TileEntityEMContractor extends TileEntity
|
|||
{
|
||||
int newOrdinal = facing.ordinal() < 5 ? facing.ordinal()+1 : 0;
|
||||
setFacing(ForgeDirection.getOrientation(newOrdinal));
|
||||
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
public ForgeDirection getFacing()
|
||||
|
@ -224,6 +228,7 @@ public class TileEntityEMContractor extends TileEntity
|
|||
public void setFacing(ForgeDirection side)
|
||||
{
|
||||
facing = side;
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue