Created
October 13, 2013 07:27
-
-
Save boq/6959143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void sendUpdateToAllTrackers(Entity tag, Packet packet) { | |
final World w = tag.worldObj; | |
Preconditions.checkArgument(w instanceof WorldServer, "This method can only be executed on server side"); | |
WorldServer server = (WorldServer)w; | |
server.getEntityTracker().sendPacketToAllPlayersTrackingEntity(tag, packet); | |
} | |
public static void sendPacketToWatchers(WorldServer server, int x, int z, Packet packet) { | |
int chunkX = x >> 4; | |
int chunkZ = z >> 4; | |
try { | |
// wrongly named, PlayerInstance is in fact chunk watchers list | |
PlayerInstance playerInstance = server.getPlayerManager().getOrCreateChunkWatcher(chunkX, chunkZ, false); | |
if (playerInstance != null) | |
playerInstance.sendToAllPlayersWatchingChunk(packet); | |
} catch (Exception e) { | |
Throwables.propagate(throwable) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment