Search in sources :

Example 6 with TileEntityTeleporter

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);
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack) TileEntityTeleporter(net.dyeo.teleporter.tileentity.TileEntityTeleporter)

Example 7 with TileEntityTeleporter

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GuiTeleporter(net.dyeo.teleporter.client.gui.inventory.GuiTeleporter) BlockPos(net.minecraft.util.math.BlockPos) TileEntityTeleporter(net.dyeo.teleporter.tileentity.TileEntityTeleporter)

Aggregations

TileEntityTeleporter (net.dyeo.teleporter.tileentity.TileEntityTeleporter)7 TileEntity (net.minecraft.tileentity.TileEntity)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 BlockPos (net.minecraft.util.math.BlockPos)2 WorldServer (net.minecraft.world.WorldServer)2 IItemHandler (net.minecraftforge.items.IItemHandler)2 ITeleportHandler (net.dyeo.teleporter.capabilities.ITeleportHandler)1 GuiTeleporter (net.dyeo.teleporter.client.gui.inventory.GuiTeleporter)1 ContainerTeleporter (net.dyeo.teleporter.inventory.ContainerTeleporter)1 TeleporterNode (net.dyeo.teleporter.teleport.TeleporterNode)1 IBlockState (net.minecraft.block.state.IBlockState)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)1 EntityWolf (net.minecraft.entity.passive.EntityWolf)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1