Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("deprecation")
- public void update(Player player)
- {
- PacketPlayOutEntityDestroy destroyEntity = new PacketPlayOutEntityDestroy(player.getEntityId());
- PacketPlayOutPlayerInfo removePlayer = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, player);
- PacketPlayOutPlayerInfo addPlayer = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, player);
- PacketPlayOutNamedEntitySpawn spawnEntity = new PacketPlayOutNamedEntitySpawn(player);
- PacketPlayOutEntityMetadata metadata = new PacketPlayOutEntityMetadata(player.getEntityId(), PacketAPI.getDataWatcher(player), true);
- PacketPlayOutHeldItemSlot helditem = new PacketPlayOutHeldItemSlot(player.getInventory().getHeldItemSlot());
- PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(player);
- PacketPlayOutPosition position = new PacketPlayOutPosition(player.getLocation());
- PacketPlayOutEntityHeadRotation headrotation = new PacketPlayOutEntityHeadRotation(player.getEntityId(), player.getLocation().getYaw());
- Bukkit.getScheduler().runTask((JavaPlugin)null, () -> {
- for (Player p1 : Bukkit.getOnlinePlayers())
- {
- if (p1.canSee(player))
- {
- removePlayer.send(p1);
- addPlayer.send(p1);
- if (p1.getEntityId() != player.getEntityId())
- {
- destroyEntity.send(p1);
- spawnEntity.send(p1);
- }
- headrotation.send(p1);
- new PacketPlayOutEntityEquipment(player.getEntityId(), EnumItemSlot.MAINHAND, player.getInventory().getItemInHand()).send(p1);
- new PacketPlayOutEntityEquipment(player.getEntityId(), EnumItemSlot.FEET, player.getInventory().getBoots()).send(p1);
- new PacketPlayOutEntityEquipment(player.getEntityId(), EnumItemSlot.LEGS, player.getInventory().getLeggings()).send(p1);
- new PacketPlayOutEntityEquipment(player.getEntityId(), EnumItemSlot.CHEST, player.getInventory().getChestplate()).send(p1);
- new PacketPlayOutEntityEquipment(player.getEntityId(), EnumItemSlot.HEAD, player.getInventory().getHelmet()).send(p1);
- }
- }
- PacketAPI.sendPacket(player, metadata);
- PacketAPI.sendPacket(player, respawn);
- position.send(player);
- helditem.send(player);
- // ep.updateAbilities();
- new PacketPlayOutUpdateHealth((float) player.getHealth(), player.getFoodLevel(), player.getSaturation());
- player.updateInventory();
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement