use of pneumaticCraft.common.tileentity.TileEntityElevatorBase in project PneumaticCraft by MineMaarten.
the class BlockElevatorBase method onNeighborBlockChange.
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityElevatorBase) {
TileEntityElevatorBase thisTe = (TileEntityElevatorBase) te;
if (thisTe.isCoreElevator()) {
TileEntityElevatorBase teAbove = getCoreTileEntity(world, x, y, z);
if (teAbove != null && teAbove != thisTe) {
for (int i = 0; i < thisTe.getSizeInventory(); i++) {
ItemStack item = thisTe.getStackInSlot(i);
if (item != null) {
ItemStack leftover = TileEntityHopper.func_145889_a(teAbove, item, 0);
thisTe.setInventorySlotContents(i, null);
if (leftover != null) {
EntityItem entity = new EntityItem(world, teAbove.xCoord + 0.5, teAbove.yCoord + 1.5, teAbove.zCoord + 0.5, leftover);
world.spawnEntityInWorld(entity);
}
}
}
}
}
}
}
use of pneumaticCraft.common.tileentity.TileEntityElevatorBase in project PneumaticCraft by MineMaarten.
the class BlockElevatorBase method onBlockAdded.
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
TileEntityElevatorBase elevatorBase = getCoreTileEntity(world, x, y, z);
if (elevatorBase != null) {
elevatorBase.updateMaxElevatorHeight();
}
}
use of pneumaticCraft.common.tileentity.TileEntityElevatorBase in project PneumaticCraft by MineMaarten.
the class BlockElevatorBase method dropInventory.
@Override
protected void dropInventory(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileEntityElevatorBase))
return;
TileEntityElevatorBase inventory = (TileEntityElevatorBase) tileEntity;
Random rand = new Random();
for (int i = getInventoryDropStartSlot(inventory); i < getInventoryDropEndSlot(inventory); i++) {
ItemStack itemStack = inventory.getRealStackInSlot(i);
if (itemStack != null && itemStack.stackSize > 0) {
float dX = rand.nextFloat() * 0.8F + 0.1F;
float dY = rand.nextFloat() * 0.8F + 0.1F;
float dZ = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, new ItemStack(itemStack.getItem(), itemStack.stackSize, itemStack.getItemDamage()));
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}
}
use of pneumaticCraft.common.tileentity.TileEntityElevatorBase in project PneumaticCraft by MineMaarten.
the class BlockElevatorBase method breakBlock.
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (world.getBlock(x, y - 1, z) == Blockss.elevatorBase) {
TileEntity te = world.getTileEntity(x, y - 1, z);
((TileEntityElevatorBase) te).moveInventoryToThis();
}
TileEntityElevatorBase elevatorBase = getCoreTileEntity(world, x, y, z);
if (elevatorBase != null) {
elevatorBase.updateMaxElevatorHeight();
}
super.breakBlock(world, x, y, z, block, meta);
}
use of pneumaticCraft.common.tileentity.TileEntityElevatorBase in project PneumaticCraft by MineMaarten.
the class BlockElevatorCaller method getElevatorBase.
private TileEntityElevatorBase getElevatorBase(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
TileEntityElevatorBase elevator = null;
if (block == Blockss.elevatorFrame) {
elevator = BlockElevatorFrame.getElevatorTE(world, x, y, z);
}
if (block == Blockss.elevatorBase) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityElevatorBase && ((TileEntityElevatorBase) te).isCoreElevator()) {
elevator = (TileEntityElevatorBase) te;
}
}
return elevator;
}
Aggregations