Certain player not rendering chunks

Discussion in 'Plugin Development' started by djbomber36, Jun 19, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    djbomber36

    Hello everyone,
    I'm working on a skin changer plugin and I'm having trouble when I have to reload the skin for the player.
    The skin works corrctly but once I have sent the packets to remove and then respawn, the player seems to not be rendering chunks. I've tested with another client and other players can see chunks normally.
    I tried different tutorials for reloading the skin but I can't find a solution for this problem.

    Here's the code for relaoding the skin for the player himself:
    Code:
                EntityPlayer ep = ((CraftPlayer) player).getHandle();
                GameProfile g = ep.getProfile();
                PropertyMap pm = g.getProperties();
                Property p = pm.get("textures").iterator().next();
    
                pm.remove("textures", p);
                pm.put("textures", new Property("textures", skinDatabase.getDataSkin(uuid), skinDatabase.getDataSignature(uuid)));
              
                skinDatabase.resetSkin(uuid);
              
                for (Player t : Bukkit.getOnlinePlayers()) {
                    t.hidePlayer(player);
                    t.showPlayer(player);
                }
              
                final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(new int[] {player.getEntityId()});
                final PacketPlayOutPlayerInfo removeInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, ep);
                final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(ep);
                final PacketPlayOutPlayerInfo addInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, ep);
                Location loc = player.getLocation().clone();
                loc.setY(loc.getY() + 0.5);
              
                ep.playerConnection.sendPacket(removeInfo);
                ep.playerConnection.sendPacket(destroy);
                ep.playerConnection.sendPacket(spawn);
                ep.playerConnection.sendPacket(addInfo);
                player.updateInventory();
              
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        player.teleport(loc);
                        ep.playerConnection.sendPacket(new PacketPlayOutRespawn(ep.dimension, ep.getWorld().getDifficulty(), ep.getWorld().getWorldData().getType(), ep.playerInteractManager.getGameMode()));
                        player.updateInventory();
                    }
                }.runTaskLater(Main.instance, 2L);
     
  2. Offline

    djbomber36

  3. Offline

    djbomber36

Thread Status:
Not open for further replies.

Share This Page