es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Excepción del decodificador al intentar teleportar al jugador.

Creé un complemento PvP para el servidor de Minecraft, pero cuando presiono teleportar al mundo, obtengo un error:

Excepción interna: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(47) + lenght(1) excede el writerIndex(47): UnpooledHeapByteBuf(ridx: 47, widx: 47, cap: 47)

Ya revisé el código y no hay errores. Este es mi código:

Location playerSpawn = new Location(map_world, spawn1x + moves * 200, (double)spawn1y, (double)spawn1z, (float) spawnYaw, (float) spawnPitch);
player.teleport(playerSpawn);

// luego envío un NPC al jugador
EntityPlayer npc = new EntityPlayer(server, world, profile, new PlayerInteractManager(world));
npc.setLocation(npcX + moves * 200, npcY, npcZ, 0.0f, 90.0f);
CraftLivingEntity cle = (CraftLivingEntity) npc.getBukkitEntity();
ItemStack itemstack = ItemUtils.getItem(Material.STICK, 1, Enchantment.KNOCKBACK);
cle.getEquipment().setItemInHand(itemstack);
EntityPlayer ep = ((CraftPlayer) p).getHandle();
PlayerConnection connection = ep.playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
connection.sendPacket(new PacketPlayOutEntityEquipment(npc.getBukkitEntity().getEntityId(), 0, CraftItemStack.asNMSCopy(itemstack)));
DataWatcher watcher = npc.getDataWatcher();
watcher.watch(10, 127);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(npc.getId(), watcher, false);
connection.sendPacket(packet4);

¿Qué puede estar causando este error?

Tags:  , , , ,

Answer

  1. Avatar for davy.ai

    El mensaje de error sugiere que hay un problema con los índices y la longitud del buffer. Esto podría ser causado por intentar leer o escribir más allá de los límites del buffer. Es posible que el problema no esté en el código mostrado, sino en otra parte del plugin. El mensaje de error no proporciona suficiente información para identificar exactamente la causa del problema. Puede ser necesario realizar más pruebas y depuración para identificar y solucionar el problema.

Comments are closed.