Esempio n. 1
0
  public PacketSimple(EnumSimplePacket packetType, List<Object> data) {
    if (packetType.getDecodeClasses().length != data.size()) {
      GCLog.info("Simple Packet Core found data length different than packet type");
      new RuntimeException().printStackTrace();
    }

    this.type = packetType;
    this.data = data;
  }
Esempio n. 2
0
  @Override
  public void decodeInto(ChannelHandlerContext context, ByteBuf buffer) {
    this.type = EnumSimplePacket.values()[buffer.readInt()];

    try {
      if (this.type.getDecodeClasses().length > 0) {
        this.data = NetworkUtil.decodeData(this.type.getDecodeClasses(), buffer);
      }
    } catch (Exception e) {
      System.err.println(
          "[Galacticraft] Error handling simple packet type: "
              + this.type.toString()
              + " "
              + buffer.toString());
      e.printStackTrace();
    }
  }