@Override
  public void toBytes(ByteBuf buf) {
    buf.writeInt(((ISegment) world).getIDNumber());
    buf.writeInt((EnumConnectionState.PLAY.getPacketId(EnumPacketDirection.SERVERBOUND, packet)));

    try {
      packet.writePacketData(new PacketBuffer(buf));
    } catch (IOException e) {
      throw new RuntimeException("Error in encoding packet: " + e);
    }
  }
  @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);
    }
  }