Search in sources :

Example 6 with TileEntityBase

use of com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase in project artisan-worktables by codetaylor.

the class SPacketWorktableTab method onMessage.

@Override
public IMessage onMessage(SPacketWorktableTab message, MessageContext ctx, TileEntity tileEntity) {
    // Reference:
    // https://github.com/SlimeKnights/TinkersConstruct/blob/master/src/main/java/slimeknights/tconstruct/tools/common/network/TinkerStationTabPacket.java
    NetHandlerPlayServer serverHandler = ctx.getServerHandler();
    EntityPlayerMP player = serverHandler.player;
    ItemStack heldStack = player.inventory.getItemStack();
    if (!heldStack.isEmpty()) {
        player.inventory.setItemStack(ItemStack.EMPTY);
    }
    if (tileEntity instanceof TileEntityBase) {
        player.openGui(ModuleWorktables.MOD_INSTANCE, 1, player.getEntityWorld(), message.blockPos.getX(), message.blockPos.getY(), message.blockPos.getZ());
    }
    if (!heldStack.isEmpty()) {
        player.inventory.setItemStack(heldStack);
        serverHandler.sendPacket(new SPacketSetSlot(-1, -1, heldStack));
    }
    return null;
}
Also used : TileEntityBase(com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase) SPacketTileEntityBase(com.codetaylor.mc.athenaeum.spi.packet.SPacketTileEntityBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SPacketSetSlot(net.minecraft.network.play.server.SPacketSetSlot) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Example 7 with TileEntityBase

use of com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase in project artisan-worktables by codetaylor.

the class SPacketWorktableTankDestroyFluid method onMessage.

@Override
public IMessage onMessage(SPacketWorktableTankDestroyFluid message, MessageContext ctx, TileEntity tileEntity) {
    if (tileEntity instanceof TileEntityBase) {
        FluidTank tank = ((TileEntityBase) tileEntity).getTank();
        tank.drain(tank.getCapacity(), true);
        ModuleWorktables.PACKET_SERVICE.sendToAllAround(new CPacketWorktableFluidUpdate(tileEntity.getPos(), tank), tileEntity);
    }
    return null;
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) TileEntityBase(com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase) SPacketTileEntityBase(com.codetaylor.mc.athenaeum.spi.packet.SPacketTileEntityBase)

Aggregations

TileEntityBase (com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase)7 SPacketTileEntityBase (com.codetaylor.mc.athenaeum.spi.packet.SPacketTileEntityBase)2 ItemStack (net.minecraft.item.ItemStack)2 FluidTank (net.minecraftforge.fluids.FluidTank)2 SPacketWorktableTab (com.codetaylor.mc.artisanworktables.modules.worktables.network.SPacketWorktableTab)1 CPacketTileEntityBase (com.codetaylor.mc.athenaeum.spi.packet.CPacketTileEntityBase)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)1 SPacketSetSlot (net.minecraft.network.play.server.SPacketSetSlot)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1