@SubscribeEvent public void registerDimension(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.END) { throw new IllegalStateException("I should be gone."); } DimensionManager.initDimension(DeltaChunk.getDimensionId()); if (!DimensionManager.shouldLoadSpawn(DeltaChunk.getDimensionId())) { throw new RuntimeException("hammerWorld is not loaded"); } if (!DimensionManager.isDimensionRegistered(DeltaChunk.getDimensionId())) { throw new RuntimeException("Hammer dimension was not registered!?"); } World hammerWorld = DimensionManager.getWorld(DeltaChunk.getDimensionId()); if (!(hammerWorld.provider instanceof HammerWorldProvider)) { throw new RuntimeException("Expected HammerWorldProvider for HammerWorld; is there a dimension ID conflict? Actual provider: " + hammerWorld.provider.getClass()); } hammerWorld.addWorldAccess(new ServerShadowWorldAccess()); int view_distance = MinecraftServer.getServer().getConfigurationManager().getViewDistance(); //the undeobfed method comes after "isPlayerWatchingChunk", also in uses of ServerConfigurationManager.getViewDistance() //It returns how many blocks are visible. DSE_ChunkUpdateRangeSquared = Math.pow(PlayerManager.getFurthestViewableBlock(view_distance) + 16*2, 2); Core.unloadBus(this); }
public void resyncChunksFull() { if (w.isRemote) return; Chunk chunk = getChunk(); final WorldServer world = (WorldServer) chunk.getWorld(); final PlayerManager pm = world.getPlayerManager(); PlayerManager.PlayerInstance watcher = pm.getPlayerInstance(chunk.xPosition, chunk.zPosition, false); if (watcher == null) return; ArrayList<EntityPlayerMP> players = new ArrayList<EntityPlayerMP>(); players.addAll(watcher.playersWatchingChunk); for (EntityPlayerMP player : players) { watcher.removePlayer(player); watcher.addPlayer(player); } Packet packet = new S21PacketChunkData(chunk, true, -1); FzNetDispatch.addPacketFrom(packet, chunk); }
public static List<EntityPlayerMP> getPlayersWatchingChunk(World world, int chunkX, int chunkZ) { if (world.isRemote || !(world instanceof WorldServer)) { return Collections.emptyList(); } ArrayList<EntityPlayerMP> playersWatching = new ArrayList<>(); WorldServer server = (WorldServer) world; PlayerManager playerManager = server.getPlayerManager(); List<EntityPlayerMP> players = server.playerEntities; for (EntityPlayerMP player : players) { if (playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) { playersWatching.add(player); } } return playersWatching; }
public void func_73252_b(EntityPlayerMP p_73252_1_) { if(this.field_73263_b.contains(p_73252_1_)) { Chunk var2 = PlayerManager.func_72692_a(this.field_73265_a).func_72964_e(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b); p_73252_1_.field_71135_a.func_72567_b(new Packet51MapChunk(var2, true, 0)); this.field_73263_b.remove(p_73252_1_); p_73252_1_.field_71129_f.remove(this.field_73264_c); if(this.field_73263_b.isEmpty()) { long var3 = (long)this.field_73264_c.field_77276_a + 2147483647L | (long)this.field_73264_c.field_77275_b + 2147483647L << 32; this.func_111196_a(var2); PlayerManager.func_72689_b(this.field_73265_a).func_76159_d(var3); PlayerManager.func_111191_d(this.field_73265_a).remove(this); if(this.field_73262_e > 0) { PlayerManager.func_72682_c(this.field_73265_a).remove(this); } this.field_73265_a.func_72688_a().field_73059_b.func_73241_b(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b); } } }
public void func_73259_a(int p_73259_1_, int p_73259_2_, int p_73259_3_) { if(this.field_73262_e == 0) { PlayerManager.func_72682_c(this.field_73265_a).add(this); } this.field_73260_f |= 1 << (p_73259_2_ >> 4); if(this.field_73262_e < 64) { short var4 = (short)(p_73259_1_ << 12 | p_73259_3_ << 8 | p_73259_2_); for(int var5 = 0; var5 < this.field_73262_e; ++var5) { if(this.field_73261_d[var5] == var4) { return; } } this.field_73261_d[this.field_73262_e++] = var4; } }
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn) { super(saveHandlerIn, info, WorldProvider.getProviderForDimension(dimensionId), profilerIn, false); this.mcServer = server; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerManager(this); this.provider.registerWorld(this); this.chunkProvider = this.createChunkProvider(); this.worldTeleporter = new Teleporter(this); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.getWorldBorder().setSize(server.getMaxWorldSize()); }
public static void sendToChunk(Packet packet, World world, int chunkX, int chunkZ) { PlayerManager playerManager = ((WorldServer)world).getPlayerManager(); for (EntityPlayerMP player : (List<EntityPlayerMP>) MinecraftServer.getServer().getConfigurationManager().playerEntityList) if(playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) sendToPlayer(packet, player); /* Commented until forge accepts access tranformer request PlayerInstance p = ((WorldServer) world).getPlayerManager().getOrCreateChunkWatcher(chunkX, chunkZ, false); if (p != null) p.sendToAllPlayersWatchingChunk(packet);*/ }
public static void addPacketFrom(Packet packet, Chunk chunk) { if (chunk.getWorld().isRemote) return; final WorldServer world = (WorldServer) chunk.getWorld(); final PlayerManager pm = world.getPlayerManager(); PlayerManager.PlayerInstance watcher = pm.getPlayerInstance(chunk.xPosition, chunk.zPosition, false); if (watcher == null) return; watcher.sendToAllPlayersWatchingChunk(packet); // The above requires an AT that is impossible to get working? /*if (chunk.worldObj.isRemote) return; final WorldServer world = (WorldServer) chunk.worldObj; final PlayerManager pm = world.getPlayerManager(); final int near = 10; final int far = 16; final int sufficientlyClose = (near*16)*(near*16); final int superlativelyFar = (far*16)*(far*16); final int chunkBlockX = chunk.xPosition*16 + 8; final int chunkBlockZ = chunk.zPosition*16 + 8; for (EntityPlayerMP player : world.playerEntities) { double dx = player.posX - chunkBlockX; double dz = player.posZ - chunkBlockZ; double dist = dx*dx + dz*dz; if (dist > superlativelyFar) continue; if (dist < sufficientlyClose || pm.isPlayerWatchingChunk(player, chunk.xPosition, chunk.zPosition)) { player.playerNetServerHandler.sendPacket(packet); } }*/ }
public static Set<EntityPlayerMP> getPlayersWatchingChunk(WorldServer world, int chunkX, int chunkZ) { PlayerManager manager = world.getPlayerManager(); Set<EntityPlayerMP> playerList = Sets.newHashSet(); for (Object o : world.playerEntities) { EntityPlayerMP player = (EntityPlayerMP)o; if (manager.isPlayerWatchingChunk(player, chunkX, chunkZ)) playerList.add(player); } return playerList; }
public void sendToPlayersWatchingChunk(IMessage message, WorldServer worldServer, int chunkX, int chunkZ) { PlayerManager.PlayerInstance pi = worldServer.getPlayerManager().getOrCreateChunkWatcher(chunkX, chunkZ, false); if (pi != null) { for (EntityPlayerMP player : (List<EntityPlayerMP>) pi.playersWatchingChunk) { sendTo(message, player); } } }
/** * Sends the specified packet to all players either in specified chunk, or at least have that chunk loaded */ public static void sendToAllWatchingChunk(Chunk chunk, Packet packet) { World world = chunk.worldObj; if (world instanceof WorldServer) { PlayerManager playerManager = ((WorldServer) world).getPlayerManager(); PlayerInstance playerInstance = playerManager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, false); if (playerInstance != null) { playerInstance.sendToAllPlayersWatchingChunk(packet); } } }
public static Set<EntityPlayer> getPlayersWatchingChunk(WorldServer world, int chunkX, int chunkZ) { final PlayerManager manager = world.getPlayerManager(); final Set<EntityPlayer> playerList = Sets.newHashSet(); for (Object o : world.playerEntities) { EntityPlayerMP player = (EntityPlayerMP) o; if (manager.isPlayerWatchingChunk(player, chunkX, chunkZ)) playerList.add(player); } return playerList; }
public PlayerInstance(PlayerManager p_i1518_1_, int p_i1518_2_, int p_i1518_3_) { this.field_73265_a = p_i1518_1_; this.field_73263_b = new ArrayList(); this.field_73261_d = new short[64]; this.field_73264_c = new ChunkCoordIntPair(p_i1518_2_, p_i1518_3_); p_i1518_1_.func_72688_a().field_73059_b.func_73158_c(p_i1518_2_, p_i1518_3_); }
public void func_73255_a(EntityPlayerMP p_73255_1_) { if(this.field_73263_b.contains(p_73255_1_)) { throw new IllegalStateException("Failed to add player. " + p_73255_1_ + " already is in chunk " + this.field_73264_c.field_77276_a + ", " + this.field_73264_c.field_77275_b); } else { if(this.field_73263_b.isEmpty()) { this.field_111198_g = PlayerManager.func_72692_a(this.field_73265_a).func_82737_E(); } this.field_73263_b.add(p_73255_1_); p_73255_1_.field_71129_f.add(this.field_73264_c); } }
public PlayerManager getPlayerManager() { return this.thePlayerManager; }
@Override public int getMaxTrackingDistance() { return PlayerManager.getFurthestViewableBlock(playerViewRadius); }
@Override public int getMaxTrackingDistance() { return PlayerManager.getFurthestViewableBlock(this.playerViewRadius); }
public PlayerManager func_73040_p() { return this.field_73063_M; }
public int func_72372_a() { return PlayerManager.func_72686_a(this.func_72395_o()); }
public void func_111194_a() { this.func_111196_a(PlayerManager.func_72692_a(this.field_73265_a).func_72964_e(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b)); }
private void func_111196_a(Chunk p_111196_1_) { p_111196_1_.field_111204_q += PlayerManager.func_72692_a(this.field_73265_a).func_82737_E() - this.field_111198_g; this.field_111198_g = PlayerManager.func_72692_a(this.field_73265_a).func_82737_E(); }
public void func_73254_a() { if(this.field_73262_e != 0) { int var1; int var2; int var3; if(this.field_73262_e == 1) { var1 = this.field_73264_c.field_77276_a * 16 + (this.field_73261_d[0] >> 12 & 15); var2 = this.field_73261_d[0] & 255; var3 = this.field_73264_c.field_77275_b * 16 + (this.field_73261_d[0] >> 8 & 15); this.func_73256_a(new Packet53BlockChange(var1, var2, var3, PlayerManager.func_72692_a(this.field_73265_a))); if(PlayerManager.func_72692_a(this.field_73265_a).func_72927_d(var1, var2, var3)) { this.func_73257_a(PlayerManager.func_72692_a(this.field_73265_a).func_72796_p(var1, var2, var3)); } } else { int var4; if(this.field_73262_e == 64) { var1 = this.field_73264_c.field_77276_a * 16; var2 = this.field_73264_c.field_77275_b * 16; this.func_73256_a(new Packet51MapChunk(PlayerManager.func_72692_a(this.field_73265_a).func_72964_e(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b), false, this.field_73260_f)); for(var3 = 0; var3 < 16; ++var3) { if((this.field_73260_f & 1 << var3) != 0) { var4 = var3 << 4; List var5 = PlayerManager.func_72692_a(this.field_73265_a).func_73049_a(var1, var4, var2, var1 + 16, var4 + 16, var2 + 16); for(int var6 = 0; var6 < var5.size(); ++var6) { this.func_73257_a((TileEntity)var5.get(var6)); } } } } else { this.func_73256_a(new Packet52MultiBlockChange(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b, this.field_73261_d, this.field_73262_e, PlayerManager.func_72692_a(this.field_73265_a))); for(var1 = 0; var1 < this.field_73262_e; ++var1) { var2 = this.field_73264_c.field_77276_a * 16 + (this.field_73261_d[var1] >> 12 & 15); var3 = this.field_73261_d[var1] & 255; var4 = this.field_73264_c.field_77275_b * 16 + (this.field_73261_d[var1] >> 8 & 15); if(PlayerManager.func_72692_a(this.field_73265_a).func_72927_d(var2, var3, var4)) { this.func_73257_a(PlayerManager.func_72692_a(this.field_73265_a).func_72796_p(var2, var3, var4)); } } } } this.field_73262_e = 0; this.field_73260_f = 0; } }