Use chunk util method that exists instead of own thing

This commit is contained in:
Vincent Lee committed 2016-05-21 12:13:37 -05:00
1 parent c9de3bcc03
commit e2e00f7ef1
2 files changed
+5 -9

No files matched your search

@@ -24,17 +24,17 @@ public final class VanillaPacketDispatcher {
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
if(tile.getWorld() instanceof WorldServer) {
WorldServer ws = ((WorldServer) tile.getWorld());
PlayerChunkMapEntry chunk = ws.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4);
SPacketUpdateTileEntity packet = tile.getUpdatePacket();
if(chunk == null)
if(packet == null)
return;
for (EntityPlayer player : ws.playerEntities) {
EntityPlayerMP playerMP = ((EntityPlayerMP) player);
if (playerMP.getDistanceSq(tile.getPos()) < 64 * 64
&& chunk.containsPlayer(playerMP)) {
playerMP.connection.sendPacket(tile.getUpdatePacket());
&& ws.getPlayerChunkMap().isPlayerWatchingChunk(playerMP, tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4)) {
playerMP.connection.sendPacket(packet);
}
}
@@ -26,16 +26,12 @@ public final class PacketHandler {
public static void sendToNearby(World world, BlockPos pos, IMessage toSend) {
if(world instanceof WorldServer) {
WorldServer ws = ((WorldServer) world);
PlayerChunkMapEntry chunk = ws.getPlayerChunkMap().getEntry(pos.getX() >> 4, pos.getZ() >> 4);
if(chunk == null)
return;
for (EntityPlayer player : ws.playerEntities) {
EntityPlayerMP playerMP = ((EntityPlayerMP) player);
if (playerMP.getDistanceSq(pos) < 64 * 64
&& chunk.containsPlayer(playerMP)) {
&& ws.getPlayerChunkMap().isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) {
HANDLER.sendTo(toSend, playerMP);
}
}