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)); }); }
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 ); } }
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); } } }
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()); }
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))); } } } }
@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 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()); }
return; PlayerChunkMapEntry watcher = manager.getEntry(chunk.x, chunk.z); if (watcher != null) { watcher.sendPacket(new SPacketChunkData(chunk, -1));
return; PlayerChunkMapEntry watcher = manager.getEntry(chunk.x, chunk.z); if (watcher != null) { watcher.sendPacket(new SPacketChunkData(chunk, -1));