@Override
  public void fromBytes(ByteBuf buf) {
    world = DimensionManager.getWorld(buf.readInt());

    try {
      packet = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.SERVERBOUND, buf.readInt());
      packet.readPacketData(new PacketBuffer(buf));
    } catch (InstantiationException | IllegalAccessException | IOException e) {
      throw new DecoderException(e);
    }
  }
Ejemplo n.º 2
0
  protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List p_decode_3_)
      throws IOException, InstantiationException, IllegalAccessException {
    if (p_decode_2_.readableBytes() != 0) {
      PacketBuffer var4 = new PacketBuffer(p_decode_2_);
      int var5 = var4.readVarIntFromBuffer();
      Packet var6 =
          ((EnumConnectionState)
                  p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get())
              .getPacket(this.direction, var5);

      if (var6 == null) {
        throw new IOException("Bad packet id " + var5);
      } else {
        var6.readPacketData(var4);

        if (var4.readableBytes() > 0) {
          throw new IOException(
              "Packet "
                  + ((EnumConnectionState)
                          p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get())
                      .getId()
                  + "/"
                  + var5
                  + " ("
                  + var6.getClass().getSimpleName()
                  + ") was larger than I expected, found "
                  + var4.readableBytes()
                  + " bytes extra whilst reading packet "
                  + var5);
        } else {
          p_decode_3_.add(var6);

          if (logger.isDebugEnabled()) {
            logger.debug(
                RECEIVED_PACKET_MARKER,
                " IN: [{}:{}] {}",
                new Object[] {
                  p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(),
                  Integer.valueOf(var5),
                  var6.getClass().getName()
                });
          }
        }
      }
    }
  }