use of net.dyeo.teleporter.tileentity.TileEntityTeleporter in project VanillaTeleporter by dyeo.
the class BlockTeleporter method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntityTeleporter tileEntityTeleporter = (TileEntityTeleporter) world.getTileEntity(pos);
if (tileEntityTeleporter != null) {
tileEntityTeleporter.removeFromNetwork();
if (tileEntityTeleporter.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
IItemHandler handler = tileEntityTeleporter.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
ItemStack stack = handler.getStackInSlot(0);
if (!stack.isEmpty()) {
stack = stack.copy();
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), stack);
}
}
}
// super _must_ be called last because it removes the tile entity
super.breakBlock(world, pos, state);
}
use of net.dyeo.teleporter.tileentity.TileEntityTeleporter in project VanillaTeleporter by dyeo.
the class GuiHandler method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == GUI_ID_TELEPORTER) {
BlockPos pos = new BlockPos(x, y, z);
TileEntity tileentity = world.getTileEntity(pos);
if (tileentity instanceof TileEntityTeleporter) {
TileEntityTeleporter tileentityteleporter = (TileEntityTeleporter) tileentity;
return new GuiTeleporter(player.inventory, tileentityteleporter);
}
}
return null;
}
Aggregations