Search in sources :

Example 1 with PacketType

use of mods.railcraft.common.util.network.RailcraftPacket.PacketType in project Railcraft by Railcraft.

the class PacketHandler method onPacketData.

private void onPacketData(ByteBuf byteBuf, EntityPlayerMP player, @Nullable IThreadListener listener) {
    RailcraftInputStream data = new RailcraftInputStream(new ByteBufInputStream(byteBuf));
    try {
        RailcraftPacket pkt;
        byte packetID = data.readByte();
        if (packetID < 0)
            return;
        // System.out.println("Packet Received: " + packetID);
        PacketType type = packetTypes[packetID];
        switch(type) {
            case GUI_RETURN:
                pkt = new PacketGuiReturn(player);
                break;
            case TILE_EXTRA_DATA:
                pkt = new PacketTileExtraData();
                break;
            case TILE_REQUEST:
                pkt = new PacketTileRequest(player);
                break;
            case GUI_INTEGER:
                pkt = new PacketGuiInteger();
                break;
            case GUI_STRING:
                pkt = new PacketGuiString();
                break;
            case GUI_WIDGET:
                pkt = new PacketGuiWidget();
                break;
            case EFFECT:
                pkt = new PacketEffect();
                break;
            case CONTROLLER_UPDATE:
            case RECEIVER_UPDATE:
            case SIGNAL_UPDATE:
                pkt = new PacketPairUpdate(type);
                break;
            case CONTROLLER_REQUEST:
            case RECEIVER_REQUEST:
            case SIGNAL_REQUEST:
                pkt = new PacketPairRequest(player, type);
                break;
            case ITEM_NBT_HAND:
                pkt = new PacketItemNBT.CurrentItem(player);
                break;
            case ITEM_NBT_TILE:
                pkt = new PacketItemNBT.RoutableTile(player);
                break;
            case KEY_PRESS:
                pkt = new PacketKeyPress(player);
                break;
            case GOLDEN_TICKET_GUI:
                pkt = new PacketTicketGui();
                break;
            case LOGBOOK_GUI:
                pkt = new PacketLogbook();
                break;
            case SHUNTING_AURA:
                pkt = new PacketShuntingAura();
                break;
            case MOVING_SOUND:
                pkt = new PacketMovingSound();
                break;
            case STOP_RECORD:
                pkt = new PacketStopRecord();
                break;
            case ENTITY_SYNC:
                pkt = new PacketEntitySync();
                break;
            default:
                return;
        }
        readPacket(pkt, data, listener);
    } catch (IOException e) {
        Game.log().throwable("Exception in PacketHandler.onPacketData", e);
    }
}
Also used : PacketType(mods.railcraft.common.util.network.RailcraftPacket.PacketType) ByteBufInputStream(io.netty.buffer.ByteBufInputStream) IOException(java.io.IOException)

Aggregations

ByteBufInputStream (io.netty.buffer.ByteBufInputStream)1 IOException (java.io.IOException)1 PacketType (mods.railcraft.common.util.network.RailcraftPacket.PacketType)1