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 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()); }
@Override public void tick() { List<PlayerChunkMapEntry> entries = getEntries(this); List<PlayerChunkMapEntry> hookedEntries = new ArrayList<>(this.hookedChunks.size()); for (PlayerChunkMapEntry entry : entries) { ChunkPos pos = entry.getPos(); if (entry.getChunk() == null) { if (this.hookedChunks.containsKey(pos)) { hookEntryChunk(entry, this.hookedChunks.get(pos)); hookedEntries.add(entry); } } } super.tick(); for (PlayerChunkMapEntry hookedEntry : hookedEntries) { hookEntryChunk(hookedEntry, null); } } }
@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()); }
private Collection<RegionTilePos> collectRequiredRegions(WorldServer world, PlayerChunkMap chunkTracker, List<PlayerChunkMapEntry> chunkEntries) { Set<RegionTilePos> requiredRegions = new LinkedHashSet<>(); for (PlayerChunkMapEntry entry : chunkEntries) { Chunk chunk = entry.getChunk(); if (chunk == null) { ChunkPos chunkPos = entry.getPos(); if (this.isChunkSaved(world, chunkPos)) { continue; } RegionTilePos regionPos = this.getRegionPos(chunkPos.getXStart(), chunkPos.getZStart()); if (!this.regionCache.containsKey(regionPos)) { if (chunkTracker instanceof PlayerChunkMapHooks.Wrapper) { ((PlayerChunkMapHooks.Wrapper) chunkTracker).hookChunk(chunkPos); } } requiredRegions.add(regionPos); } } return requiredRegions; }
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); } } }
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))); } } } }
watcher.sendPacket(new SPacketChunkData(chunk, -1));
watcher.sendPacket(new SPacketChunkData(chunk, -1));