/** * Send message to all within 64 blocks that have this chunk loaded */ public static void sendToNearby(World world, BlockPos pos, IMessage toSend) { if(world instanceof WorldServer) { WorldServer ws = (WorldServer) world; for (EntityPlayer player : ws.playerEntities) { EntityPlayerMP playerMP = (EntityPlayerMP) player; if (playerMP.getDistanceSq(pos) < 64 * 64 && ws.getPlayerChunkMap().isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) { HANDLER.sendTo(toSend, playerMP); } } } }
private void clearPotions(EntityPlayer player) { int posXInt = MathHelper.floor(posX); int posZInt = MathHelper.floor(posZ); List<Potion> potionsToRemove = player.getActivePotionEffects().stream() .filter(effect -> effect.getDuration() < 160 && effect.getIsAmbient() && !effect.getPotion().isBadEffect()) .map(PotionEffect::getPotion) .distinct() .collect(Collectors.toList()); potionsToRemove.forEach(potion -> { player.removePotionEffect(potion); ((WorldServer) world).getPlayerChunkMap().getEntry(posXInt >> 4, posZInt >> 4).sendPacket(new SPacketRemoveEntityEffect(player.getEntityId(), potion)); }); }
WorldServer w = (WorldServer) nmsChunk.getWorld(); PlayerChunkMap chunkMap = w.getPlayerChunkMap(); if (!chunkMap.contains(x, z)) { return; for (EntityPlayer player : w.playerEntities) { if (player instanceof EntityPlayerMP) { if (chunkMap.isPlayerWatchingChunk((EntityPlayerMP) player, x, z)) { players.add((EntityPlayerMP) player);
@Override public void setInventorySlotContents(int slot, ItemStack stack) { super.setInventorySlotContents(slot, stack); if (slot == SLOT_LIQUID && world instanceof WorldServer) { ((WorldServer) world).getPlayerChunkMap().markBlockForUpdate(pos); } }
if (chunk != null && !worldServer.playerChunkMap.contains(chunk.x, chunk.z)) { frozenShips.add(wrapper);
@Override @Method(modid = "appliedenergistics2") public void connectionsChanged() { super.connectionsChanged(); BlockPos pos = getBundle().getLocation(); onNodeChanged(pos); IGridNode node = getNode(); if (node != null) { node.updateState(); World world = node.getWorld(); if (!world.isRemote && world instanceof WorldServer) ((WorldServer) world).getPlayerChunkMap().markBlockForUpdate(pos); } }
public static void sendToAllTrackingChunk(World world, int cx, int cz, PacketBase pkt) { WorldServer server = (WorldServer) world; for (EntityPlayer p : server.playerEntities) { if (server.getPlayerChunkMap().isPlayerWatchingChunk((EntityPlayerMP) p, cx, cz)) { sendToPlayer((EntityPlayerMP) p, pkt); } } }
public static void sendChunk( final Chunk c, final int verticalBits ) { try { final WorldServer ws = (WorldServer) c.getWorld(); final PlayerChunkMap pm = ws.getPlayerChunkMap(); final PlayerChunkMapEntry playerInstance = pm.getEntry( c.x, c.z ); if( playerInstance != null ) { playerInstance.sendPacket( new SPacketChunkData( c, verticalBits ) ); } } catch( final Throwable t ) { AELog.debug( t ); } }
private List<EntityPlayerMP> getAllPlayersWatchingBlock(World world, int x, int z) { List<EntityPlayerMP> ret = new ArrayList<>(); if(world instanceof WorldServer) { PlayerChunkMap playerManager = ((WorldServer)world).getPlayerChunkMap(); for (EntityPlayerMP player : ((WorldServer) getWorld()).getMinecraftServer().getPlayerList().getPlayers()) { Chunk chunk = world.getChunkFromChunkCoords(x >> 4, z >> 4); if (playerManager.isPlayerWatchingChunk(player, chunk.x, chunk.z)) { ret.add(player); } } } return ret; }
public static void dispatchTEToNearbyPlayers(TileEntity tile) { SPacketUpdateTileEntity packet = tile.getUpdatePacket(); if(packet != null && tile.getWorld() instanceof WorldServer) { PlayerChunkMapEntry chunk = ((WorldServer) tile.getWorld()).getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4); if(chunk != null) { chunk.sendPacket(packet); } } }
private static void flushChanges(int chunkX, int chunkY, int dim, ChangeList list) { WorldServer world = DimensionManager.getWorld(dim); PlayerChunkMap manager = world.getPlayerChunkMap(); for (EntityPlayer player : world.playerEntities) { if (manager.isPlayerWatchingChunk((EntityPlayerMP) player, chunkX, chunkY)) { wrapper.sendTo(new PacketMultipartAction(list), (EntityPlayerMP) player); } } }
public static Set<EntityPlayerMP> getPlayersWatchingChunk(WorldServer world, int chunkX, int chunkZ) { final PlayerChunkMapEntry playerChunkMap = world.getPlayerChunkMap().getEntry(chunkX, chunkZ); if (playerChunkMap == null) return ImmutableSet.of(); return ImmutableSet.copyOf(playerChunkMap.getWatchingPlayers()); }
public static <P extends IForestryPacketClient> void sendNetworkPacket(P packet, BlockPos pos, World world) { if (!(world instanceof WorldServer)) { return; } WorldServer worldServer = (WorldServer) world; PlayerChunkMap playerManager = worldServer.getPlayerChunkMap(); int chunkX = pos.getX() >> 4; int chunkZ = pos.getZ() >> 4; for (Object playerObj : world.playerEntities) { if (playerObj instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) playerObj; if (playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) { sendToPlayer(packet, player); } } } }
private void updateClient(@Nonnull Chunk chunk, String key, IChunkData<?> cd) { if (cd.requiresClientSync()) { NBTTagCompound tag = new NBTTagCompound(); cd.writeToNBT(chunk, tag); PlayerChunkMapEntry entry = ((WorldServer)chunk.getWorld()).getPlayerChunkMap().getEntry(chunk.x, chunk.z); if (entry != null) { entry.sendPacket(Chisel.network.getPacketFrom(new MessageChunkData(chunk, key, tag))); } } } }
public static <P extends IPacket> void sendNetworkPacket(P packet, BlockPos pos, World world) { if (!(world instanceof WorldServer)) { return; } WorldServer worldServer = (WorldServer) world; PlayerChunkMap playerManager = worldServer.getPlayerChunkMap(); int chunkX = pos.getX() >> 4; int chunkZ = pos.getZ() >> 4; for (Object playerObj : world.playerEntities) { if (playerObj instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) playerObj; if (playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) { sendToPlayer(packet, player); } } } }
@SuppressWarnings ("SuspiciousMethodCalls") public void setLight(boolean lit) { this.lit = lit; if (chunks == null) { buildMap(); } if (worldGrid.worldObj instanceof WorldServer) { PacketBase packet = new PacketLight(lit, this); WorldServer dimension = (WorldServer) worldGrid.worldObj; PlayerChunkMap manger = dimension.getPlayerChunkMap(); for (EntityPlayer player : dimension.playerEntities) { for (ChunkCoord chunk : chunks) { PlayerChunkMapEntry inst = manger.getEntry(chunk.chunkX, chunk.chunkZ); if (inst != null && inst.containsPlayer((EntityPlayerMP) player)) { PacketHandler.sendTo(packet, player); break; } } } for (DuctUnitLight block : Iterables.concat(nodeSet, idleSet)) { block.checkLight(); } } }
public void sendToAllAround(IMessage packet, BlockPos pos, World world) { if (!(world instanceof WorldServer)) { return; } WorldServer worldServer = (WorldServer) world; PlayerChunkMap playerManager = worldServer.getPlayerChunkMap(); int chunkX = pos.getX() >> 4; int chunkZ = pos.getZ() >> 4; for (Object playerObj : world.playerEntities) { if (playerObj instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) playerObj; if (playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) { sendTo(packet, player); } } } }
public static void dispatchTEToNearbyPlayers(TileEntity tile) { WorldServer world = (WorldServer) tile.getWorld(); PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4); if (entry == null) return; for (EntityPlayerMP player : entry.getWatchingPlayers()) ((EntityPlayerMP) player).connection.sendPacket(tile.getUpdatePacket()); }
EntityPlayerMP player = (EntityPlayerMP) playerObj; if (playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) { if (updatePacket == null) { updatePacket = getUpdatePacket();
return; PlayerChunkMapEntry watcher = manager.getEntry(chunk.x, chunk.z); if (watcher != null) { watcher.sendPacket(new SPacketChunkData(chunk, -1));