Minor refractor/cleanup on belts
This commit is contained in:
parent
e5d68fb593
commit
2b4bac211d
2 changed files with 295 additions and 301 deletions
|
@ -21,361 +21,355 @@ import calclavia.lib.render.block.BlockRenderingHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
/**
|
/** The block for the actual conveyor belt!
|
||||||
* The block for the actual conveyor belt!
|
|
||||||
*
|
*
|
||||||
* @author Calclavia, DarkGuardsman
|
* @author Calclavia, DarkGuardsman */
|
||||||
*/
|
|
||||||
public class BlockConveyorBelt extends BlockTile
|
public class BlockConveyorBelt extends BlockTile
|
||||||
{
|
{
|
||||||
public BlockConveyorBelt(int id)
|
public BlockConveyorBelt(int id)
|
||||||
{
|
{
|
||||||
super(id, UniversalElectricity.machine);
|
super(id, UniversalElectricity.machine);
|
||||||
setTextureName(Reference.PREFIX + "material_metal_side");
|
setTextureName(Reference.PREFIX + "material_metal_side");
|
||||||
setBlockBounds(0, 0, 0, 1, 0.3f, 1);
|
setBlockBounds(0, 0, 0, 1, 0.3f, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockAdded(World world, int x, int y, int z)
|
public void onBlockAdded(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
TileEntity t = world.getBlockTileEntity(x, y, z);
|
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (tile instanceof TileConveyorBelt)
|
||||||
|
((TileConveyorBelt) tile).mechanicalNode.reconstruct();
|
||||||
|
}
|
||||||
|
|
||||||
if (t != null && t instanceof TileConveyorBelt)
|
@Override
|
||||||
{
|
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
|
||||||
TileConveyorBelt tileEntity = (TileConveyorBelt) t;
|
{
|
||||||
tileEntity.mechanicalNode.reconstruct();
|
if (world.getBlockTileEntity(x, y, z) instanceof TileConveyorBelt)
|
||||||
}
|
{
|
||||||
}
|
TileConveyorBelt tileEntity = (TileConveyorBelt) world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
@Override
|
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
|
||||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
|
{
|
||||||
{
|
this.setBlockBounds(0f, 0f, 0f, 1f, 0.96f, 1f);
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileConveyorBelt)
|
return;
|
||||||
{
|
}
|
||||||
TileConveyorBelt tileEntity = (TileConveyorBelt) world.getBlockTileEntity(x, y, z);
|
if (tileEntity.getSlant() == SlantType.TOP)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0f, 0.68f, 0f, 1f, 0.96f, 1f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
|
this.setBlockBounds(0f, 0f, 0f, 1f, 0.3f, 1f);
|
||||||
{
|
}
|
||||||
this.setBlockBounds(0f, 0f, 0f, 1f, 0.96f, 1f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (tileEntity.getSlant() == SlantType.TOP)
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0f, 0.68f, 0f, 1f, 0.96f, 1f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setBlockBounds(0f, 0f, 0f, 1f, 0.3f, 1f);
|
@Override
|
||||||
}
|
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
TileEntity t = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
@Override
|
if (t != null && t instanceof TileConveyorBelt)
|
||||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
|
{
|
||||||
{
|
TileConveyorBelt tileEntity = (TileConveyorBelt) t;
|
||||||
TileEntity t = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (t != null && t instanceof TileConveyorBelt)
|
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
|
||||||
{
|
{
|
||||||
TileConveyorBelt tileEntity = (TileConveyorBelt) t;
|
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, y + this.minY, z + this.minZ, (double) x + 1, (double) y + 1, (double) z + 1);
|
||||||
|
}
|
||||||
|
if (tileEntity.getSlant() == SlantType.TOP)
|
||||||
|
{
|
||||||
|
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, (double) y + 0.68f, z + this.minZ, x + this.maxX, (double) y + 0.98f, z + this.maxZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
|
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
|
||||||
{
|
}
|
||||||
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, y + this.minY, z + this.minZ, (double) x + 1, (double) y + 1, (double) z + 1);
|
|
||||||
}
|
|
||||||
if (tileEntity.getSlant() == SlantType.TOP)
|
|
||||||
{
|
|
||||||
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, (double) y + 0.68f, z + this.minZ, x + this.maxX, (double) y + 0.98f, z + this.maxZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
|
@Override
|
||||||
}
|
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||||
|
{
|
||||||
|
TileEntity t = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
@Override
|
if (t != null && t instanceof TileConveyorBelt)
|
||||||
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
{
|
||||||
{
|
TileConveyorBelt tile = (TileConveyorBelt) t;
|
||||||
TileEntity t = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (t != null && t instanceof TileConveyorBelt)
|
if (tile.getSlant() == SlantType.UP || tile.getSlant() == SlantType.DOWN)
|
||||||
{
|
{
|
||||||
TileConveyorBelt tile = (TileConveyorBelt) t;
|
AxisAlignedBB boundBottom = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.3, z + 1);
|
||||||
|
AxisAlignedBB boundTop = null;
|
||||||
|
|
||||||
if (tile.getSlant() == SlantType.UP || tile.getSlant() == SlantType.DOWN)
|
ForgeDirection direction = tile.getDirection();
|
||||||
{
|
|
||||||
AxisAlignedBB boundBottom = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.3, z + 1);
|
|
||||||
AxisAlignedBB boundTop = null;
|
|
||||||
|
|
||||||
ForgeDirection direction = tile.getDirection();
|
if (tile.getSlant() != SlantType.NONE)
|
||||||
|
{
|
||||||
|
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.1, z + 1);
|
||||||
|
|
||||||
if (tile.getSlant() != SlantType.NONE)
|
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
|
||||||
{
|
{
|
||||||
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.1, z + 1);
|
par6List.add(newBounds);
|
||||||
|
}
|
||||||
|
|
||||||
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
|
return;
|
||||||
{
|
}
|
||||||
par6List.add(newBounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
if (tile.getSlant() == SlantType.UP)
|
||||||
}
|
{
|
||||||
|
if (direction.offsetX > 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x + (float) direction.offsetX / 2, y, z, x + 1, y + 0.8, z + 1);
|
||||||
|
}
|
||||||
|
else if (direction.offsetX < 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + (float) direction.offsetX / -2, y + 0.8, z + 1);
|
||||||
|
}
|
||||||
|
else if (direction.offsetZ > 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z + (float) direction.offsetZ / 2, x + 1, y + 0.8, z + 1);
|
||||||
|
}
|
||||||
|
else if (direction.offsetZ < 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.8, z + (float) direction.offsetZ / -2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tile.getSlant() == SlantType.DOWN)
|
||||||
|
{
|
||||||
|
if (direction.offsetX > 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + (float) direction.offsetX / 2, y + 0.8, z + 1);
|
||||||
|
}
|
||||||
|
else if (direction.offsetX < 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x + (float) direction.offsetX / -2, y, z, x + 1, y + 0.8, z + 1);
|
||||||
|
}
|
||||||
|
else if (direction.offsetZ > 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.8, z + (float) direction.offsetZ / 2);
|
||||||
|
}
|
||||||
|
else if (direction.offsetZ < 0)
|
||||||
|
{
|
||||||
|
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z + (float) direction.offsetZ / -2, x + 1, y + 0.8, z + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tile.getSlant() == SlantType.UP)
|
if (par5AxisAlignedBB.intersectsWith(boundBottom))
|
||||||
{
|
{
|
||||||
if (direction.offsetX > 0)
|
par6List.add(boundBottom);
|
||||||
{
|
}
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x + (float) direction.offsetX / 2, y, z, x + 1, y + 0.8, z + 1);
|
if (boundTop != null && par5AxisAlignedBB.intersectsWith(boundTop))
|
||||||
}
|
{
|
||||||
else if (direction.offsetX < 0)
|
par6List.add(boundTop);
|
||||||
{
|
}
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + (float) direction.offsetX / -2, y + 0.8, z + 1);
|
|
||||||
}
|
|
||||||
else if (direction.offsetZ > 0)
|
|
||||||
{
|
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z + (float) direction.offsetZ / 2, x + 1, y + 0.8, z + 1);
|
|
||||||
}
|
|
||||||
else if (direction.offsetZ < 0)
|
|
||||||
{
|
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.8, z + (float) direction.offsetZ / -2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (tile.getSlant() == SlantType.DOWN)
|
|
||||||
{
|
|
||||||
if (direction.offsetX > 0)
|
|
||||||
{
|
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + (float) direction.offsetX / 2, y + 0.8, z + 1);
|
|
||||||
}
|
|
||||||
else if (direction.offsetX < 0)
|
|
||||||
{
|
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x + (float) direction.offsetX / -2, y, z, x + 1, y + 0.8, z + 1);
|
|
||||||
}
|
|
||||||
else if (direction.offsetZ > 0)
|
|
||||||
{
|
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.8, z + (float) direction.offsetZ / 2);
|
|
||||||
}
|
|
||||||
else if (direction.offsetZ < 0)
|
|
||||||
{
|
|
||||||
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z + (float) direction.offsetZ / -2, x + 1, y + 0.8, z + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (par5AxisAlignedBB.intersectsWith(boundBottom))
|
return;
|
||||||
{
|
}
|
||||||
par6List.add(boundBottom);
|
|
||||||
}
|
|
||||||
if (boundTop != null && par5AxisAlignedBB.intersectsWith(boundTop))
|
|
||||||
{
|
|
||||||
par6List.add(boundTop);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
if (tile.getSlant() == SlantType.TOP)
|
||||||
}
|
{
|
||||||
|
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y + 0.68, z, x + 1, y + 0.98, z + 1);
|
||||||
|
|
||||||
if (tile.getSlant() == SlantType.TOP)
|
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
|
||||||
{
|
{
|
||||||
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y + 0.68, z, x + 1, y + 0.98, z + 1);
|
par6List.add(newBounds);
|
||||||
|
}
|
||||||
|
|
||||||
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
|
return;
|
||||||
{
|
}
|
||||||
par6List.add(newBounds);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.1, z + 1);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.1, z + 1);
|
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
|
||||||
|
{
|
||||||
|
par6List.add(newBounds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
|
@Override
|
||||||
{
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack)
|
||||||
par6List.add(newBounds);
|
{
|
||||||
}
|
super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, stack);
|
||||||
}
|
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||||
|
int change = 2;
|
||||||
|
|
||||||
@Override
|
switch (angle)
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack)
|
{
|
||||||
{
|
case 0:
|
||||||
super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, stack);
|
change = 3;
|
||||||
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
break;
|
||||||
int change = 2;
|
case 1:
|
||||||
|
change = 4;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
change = 2;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
change = 5;
|
||||||
|
break;
|
||||||
|
|
||||||
switch (angle)
|
}
|
||||||
{
|
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
||||||
case 0:
|
}
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||||
}
|
{
|
||||||
|
int original = world.getBlockMetadata(x, y, z);
|
||||||
|
int change = 2;
|
||||||
|
|
||||||
@Override
|
switch (original)
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
{
|
||||||
{
|
case 2:
|
||||||
int original = world.getBlockMetadata(x, y, z);
|
change = 4;
|
||||||
int change = 2;
|
break;
|
||||||
|
case 3:
|
||||||
|
change = 5;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
change = 3;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
change = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
switch (original)
|
}
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
||||||
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
@Override
|
||||||
}
|
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
TileConveyorBelt tileEntity = (TileConveyorBelt) world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
@Override
|
int slantOrdinal = tileEntity.getSlant().ordinal() + 1;
|
||||||
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
TileConveyorBelt tileEntity = (TileConveyorBelt) world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
int slantOrdinal = tileEntity.getSlant().ordinal() + 1;
|
if (slantOrdinal >= SlantType.values().length)
|
||||||
|
{
|
||||||
|
slantOrdinal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (slantOrdinal >= SlantType.values().length)
|
tileEntity.setSlant(SlantType.values()[slantOrdinal]);
|
||||||
{
|
|
||||||
slantOrdinal = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tileEntity.setSlant(SlantType.values()[slantOrdinal]);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
/** Moves the entity if the belt is powered. */
|
||||||
}
|
@Override
|
||||||
|
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
/** Moves the entity if the belt is powered. */
|
if (tileEntity instanceof TileConveyorBelt)
|
||||||
@Override
|
{
|
||||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
TileConveyorBelt tile = (TileConveyorBelt) tileEntity;
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileConveyorBelt)
|
if (tile.ignoreList.contains(entity))
|
||||||
{
|
{
|
||||||
TileConveyorBelt tile = (TileConveyorBelt) tileEntity;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (tile.ignoreList.contains(entity))
|
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
|
||||||
{
|
{
|
||||||
return;
|
double maxSpeed = tile.getMoveVelocity() / 20;
|
||||||
}
|
|
||||||
|
|
||||||
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
|
if (maxSpeed > 0)
|
||||||
{
|
{
|
||||||
double maxSpeed = tile.getMoveVelocity() / 20;
|
SlantType slantType = tile.getSlant();
|
||||||
|
ForgeDirection direction = tile.getDirection();
|
||||||
|
|
||||||
if (maxSpeed > 0)
|
if (slantType != SlantType.NONE)
|
||||||
{
|
{
|
||||||
SlantType slantType = tile.getSlant();
|
entity.onGround = false;
|
||||||
ForgeDirection direction = tile.getDirection();
|
}
|
||||||
|
|
||||||
if (slantType != SlantType.NONE)
|
if (slantType == SlantType.UP)
|
||||||
{
|
{
|
||||||
entity.onGround = false;
|
// We need at least 0.25 to move items up.
|
||||||
}
|
entity.motionY = maxSpeed * 3;// Math.max(0.25, maxSpeed);
|
||||||
|
}
|
||||||
|
else if (slantType == SlantType.DOWN)
|
||||||
|
{
|
||||||
|
entity.motionY = -maxSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
if (slantType == SlantType.UP)
|
if (direction.offsetX != 0)
|
||||||
{
|
{
|
||||||
// We need at least 0.25 to move items up.
|
entity.motionX = direction.offsetX * maxSpeed;
|
||||||
entity.motionY = maxSpeed * 3;// Math.max(0.25, maxSpeed);
|
entity.motionZ /= 2;
|
||||||
}
|
}
|
||||||
else if (slantType == SlantType.DOWN)
|
|
||||||
{
|
|
||||||
entity.motionY = -maxSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (direction.offsetX != 0)
|
if (direction.offsetZ != 0)
|
||||||
{
|
{
|
||||||
entity.motionX = direction.offsetX * maxSpeed;
|
entity.motionZ = direction.offsetZ * maxSpeed;
|
||||||
entity.motionZ /= 2;
|
entity.motionX /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction.offsetZ != 0)
|
if (entity instanceof EntityItem)
|
||||||
{
|
{
|
||||||
entity.motionZ = direction.offsetZ * maxSpeed;
|
if (direction.offsetX != 0)
|
||||||
entity.motionX /= 2;
|
{
|
||||||
}
|
double difference = (z + 0.5) - entity.posZ;
|
||||||
|
entity.motionZ += difference * 0.1;
|
||||||
|
}
|
||||||
|
else if (direction.offsetZ != 0)
|
||||||
|
{
|
||||||
|
double difference = (x + 0.5) - entity.posX;
|
||||||
|
entity.motionX += difference * 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
if (entity instanceof EntityItem)
|
((EntityItem) entity).age = 0;
|
||||||
{
|
|
||||||
if (direction.offsetX != 0)
|
|
||||||
{
|
|
||||||
double difference = (z + 0.5) - entity.posZ;
|
|
||||||
entity.motionZ += difference * 0.1;
|
|
||||||
}
|
|
||||||
else if (direction.offsetZ != 0)
|
|
||||||
{
|
|
||||||
double difference = (x + 0.5) - entity.posX;
|
|
||||||
entity.motionX += difference * 0.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
((EntityItem) entity).age = 0;
|
boolean foundSneaking = false;
|
||||||
|
for (EntityPlayer player : (List<EntityPlayer>) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)))
|
||||||
|
{
|
||||||
|
if (player.isSneaking())
|
||||||
|
foundSneaking = true;
|
||||||
|
}
|
||||||
|
|
||||||
boolean foundSneaking = false;
|
if (foundSneaking)
|
||||||
for (EntityPlayer player : (List<EntityPlayer>) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)))
|
((EntityItem) entity).delayBeforeCanPickup = 0;
|
||||||
{
|
else
|
||||||
if (player.isSneaking())
|
((EntityItem) entity).delayBeforeCanPickup = 20;
|
||||||
foundSneaking = true;
|
entity.onGround = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (foundSneaking)
|
/** Returns the TileEntity used by this block. */
|
||||||
((EntityItem) entity).delayBeforeCanPickup = 0;
|
@Override
|
||||||
else
|
public TileEntity createNewTileEntity(World world)
|
||||||
((EntityItem) entity).delayBeforeCanPickup = 20;
|
{
|
||||||
entity.onGround = false;
|
return new TileConveyorBelt();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the TileEntity used by this block. */
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World var1)
|
public int getRenderType()
|
||||||
{
|
{
|
||||||
return new TileConveyorBelt();
|
return BlockRenderingHandler.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@Override
|
||||||
@Override
|
public boolean isOpaqueCube()
|
||||||
public int getRenderType()
|
{
|
||||||
{
|
return false;
|
||||||
return BlockRenderingHandler.ID;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOpaqueCube()
|
@SideOnly(Side.CLIENT)
|
||||||
{
|
public boolean renderAsNormalBlock()
|
||||||
return false;
|
{
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
public int damageDropped(int par1)
|
||||||
public boolean renderAsNormalBlock()
|
{
|
||||||
{
|
return 0;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int par1)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
|
||||||
|
|
||||||
if (this.worldObj.isRemote)
|
if (this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
if (this.ticks % 10 == 0 && this.worldObj.isRemote && this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) != Mechanical.blockConveyorBelt.blockID && this.worldObj.getBlockId(xCoord, yCoord, zCoord - 1) != Mechanical.blockConveyorBelt.blockID)
|
if (this.ticks % 10 == 0 && this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) != Mechanical.blockConveyorBelt.blockID && this.worldObj.getBlockId(xCoord, yCoord, zCoord - 1) != Mechanical.blockConveyorBelt.blockID)
|
||||||
{
|
{
|
||||||
worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "conveyor", 0.5f, 0.5f + 0.15f * (float) getMoveVelocity(), true);
|
worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "conveyor", 0.5f, 0.5f + 0.15f * (float) getMoveVelocity(), true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue