net.minecraft.entity.EntityTracker Java Examples
The following examples show how to use
net.minecraft.entity.EntityTracker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 6 votes |
private void showPlayer0(@Nullable Plugin plugin, Player player) { Validate.notNull(player, "shown player cannot be null"); if (getHandle().connection == null) return; if (equals(player)) return; Set<WeakReference<Plugin>> hidingPlugins = hiddenPlayers.get(player.getUniqueId()); if (hidingPlugins == null) { return; // Player isn't hidden } hidingPlugins.remove(getPluginWeakReference(plugin)); if (!hidingPlugins.isEmpty()) { return; // Some other plugins still want the player hidden } hiddenPlayers.remove(player.getUniqueId()); EntityTracker tracker = ((WorldServer) entity.world).entityTracker; EntityPlayerMP other = ((CraftPlayer) player).getHandle(); getHandle().connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, other)); EntityTrackerEntry entry = tracker.trackedEntityHashTable.lookup(other.getEntityId()); if (entry != null && !entry.trackingPlayers.contains(getHandle())) { entry.updatePlayerEntity(getHandle()); } }
Example #2
Source File: CraftPlayer.java From Thermos with GNU General Public License v3.0 | 6 votes |
public void hidePlayer(Player player) { Validate.notNull(player, "hidden player cannot be null"); if (getHandle().playerNetServerHandler == null) return; if (equals(player)) return; if (hiddenPlayers.contains(player.getUniqueId())) return; hiddenPlayers.add(player.getUniqueId()); //remove this player from the hidden player's EntityTrackerEntry net.minecraft.entity.EntityTracker tracker = ((net.minecraft.world.WorldServer) entity.worldObj).theEntityTracker; net.minecraft.entity.player.EntityPlayerMP other = ((CraftPlayer) player).getHandle(); net.minecraft.entity.EntityTrackerEntry entry = (net.minecraft.entity.EntityTrackerEntry) tracker.trackedEntityIDs.lookup(other.getEntityId()); if (entry != null) { entry.removePlayerFromTracker(getHandle()); } //remove the hidden player from this player user list getHandle().playerNetServerHandler.sendPacket(new net.minecraft.network.play.server.S38PacketPlayerListItem(player.getPlayerListName(), false, 9999)); }
Example #3
Source File: CraftPlayer.java From Thermos with GNU General Public License v3.0 | 6 votes |
public void showPlayer(Player player) { Validate.notNull(player, "shown player cannot be null"); if (getHandle().playerNetServerHandler == null) return; if (equals(player)) return; if (!hiddenPlayers.contains(player.getUniqueId())) return; hiddenPlayers.remove(player.getUniqueId()); EntityTracker tracker = ((WorldServer) entity.worldObj).theEntityTracker; EntityPlayerMP other = ((CraftPlayer) player).getHandle(); EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntityIDs.lookup(other.getEntityId()); if (entry != null) { entry.removePlayerFromTracker(getHandle()); } getHandle().playerNetServerHandler.sendPacket(new S38PacketPlayerListItem(player.getPlayerListName(), false, 9999)); }
Example #4
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 5 votes |
private void hidePlayer0(@Nullable Plugin plugin, Player player) { Validate.notNull(player, "hidden player cannot be null"); if (getHandle().connection == null) return; if (equals(player)) return; Set<WeakReference<Plugin>> hidingPlugins = hiddenPlayers.get(player.getUniqueId()); if (hidingPlugins != null) { // Some plugins are already hiding the player. Just mark that this // plugin wants the player hidden too and end. hidingPlugins.add(getPluginWeakReference(plugin)); return; } hidingPlugins = new HashSet<>(); hidingPlugins.add(getPluginWeakReference(plugin)); hiddenPlayers.put(player.getUniqueId(), hidingPlugins); // Remove this player from the hidden player's EntityTrackerEntry EntityTracker tracker = ((WorldServer) entity.world).entityTracker; EntityPlayerMP other = ((CraftPlayer) player).getHandle(); EntityTrackerEntry entry = tracker.trackedEntityHashTable.lookup(other.getEntityId()); if (entry != null) { entry.removeTrackedPlayerSymmetric(getHandle()); } // Remove the hidden player from this player user list, if they're on it if (other.sentListPacket) { getHandle().connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.REMOVE_PLAYER, other)); } }
Example #5
Source File: NetUtils.java From OpenModsLib with MIT License | 5 votes |
public static Set<EntityPlayerMP> getPlayersWatchingEntity(WorldServer server, Entity entity) { final EntityTracker tracker = server.getEntityTracker(); @SuppressWarnings("unchecked") final Set<? extends EntityPlayerMP> trackingPlayers = (Set<? extends EntityPlayerMP>)tracker.getTrackingPlayers(entity); return ImmutableSet.copyOf(trackingPlayers); }