Search in sources :

Example 1 with PacketSlotChange

use of buildcraft.core.lib.network.PacketSlotChange in project BuildCraft by BuildCraft.

the class PacketHandlerTransport method channelRead0.

/**
 * TODO: A lot of this is based on the player to retrieve the world. Passing a dimension id would be more
 * appropriate. More generally, it seems like a lot of these packets could be replaced with tile-based RPCs.
 */
// @Override
@Deprecated
protected void channelRead0(ChannelHandlerContext ctx, Packet packet) {
    // super.channelRead0(ctx, packet);
    try {
        INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
        EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
        // packet.getID();
        int packetID = 0;
        switch(packetID) {
            case PacketIds.PIPE_POWER:
                // onPacketPower(player, (PacketPowerUpdate) packet);
                break;
            case PacketIds.PIPE_LIQUID:
                // action will have happened already at read time
                break;
            case PacketIds.PIPE_TRAVELER:
                {
                    // onPipeTravelerUpdate(player, (PacketPipeTransportTraveler) packet);
                    break;
                }
            case PacketIds.PIPE_ITEMSTACK:
                {
                    // action will have happened already at read time
                    break;
                }
            /**
             * SERVER SIDE *
             */
            case PacketIds.DIAMOND_PIPE_SELECT:
                {
                    onDiamondPipeSelect(player, (PacketSlotChange) packet);
                    break;
                }
            case PacketIds.EMERALD_PIPE_SELECT:
                {
                    onEmeraldPipeSelect(player, (PacketSlotChange) packet);
                    break;
                }
            case PacketIds.PIPE_ITEMSTACK_REQUEST:
                {
                    ((PacketPipeTransportItemStackRequest) packet).sendDataToPlayer(player);
                    break;
                }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : INetHandler(net.minecraft.network.INetHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketSlotChange(buildcraft.core.lib.network.PacketSlotChange)

Example 2 with PacketSlotChange

use of buildcraft.core.lib.network.PacketSlotChange in project BuildCraft by BuildCraft.

the class TileAdvancedCraftingTable method updateCraftingMatrix.

@Override
public void updateCraftingMatrix(int slot, ItemStack stack) {
    craftingSlots.setInventorySlotContents(slot, stack);
    updateRecipe();
    if (worldObj.isRemote) {
        PacketSlotChange packet = new PacketSlotChange(this, slot, stack);
        BuildCraftSilicon.instance.sendToServer(packet);
    }
}
Also used : PacketSlotChange(buildcraft.core.lib.network.PacketSlotChange)

Aggregations

PacketSlotChange (buildcraft.core.lib.network.PacketSlotChange)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 INetHandler (net.minecraft.network.INetHandler)1