WorldManager
Server world listener: relays S25 break progress, S28 effects and S29 sounds to players near the event.
Updated 2026-09-12
Packets Referenced (3)
Related Vanilla Internals
Deep Analysis
IWorldAccess bridge between WorldServer events and ServerConfigurationManager broadcasts. Applies volume-scaled and fixed radii with dimension gating. Forwards block updates to PlayerManager chunk map. Manages entity tracker add/remove.
Key Methods in Depth (8)
Broadcast named sound with volume-scaled range.
This IWorldAccess hook broadcasts a named sound to nearby players in the same dimension. It is called by world simulation when a block or entity emits a sound. It resolves recipients via ServerConfigurationManager.sendToAllNear at the exact x y z origin. The radius rule is volume scaled: 16.0D by default, or 16.0F times volume when volume exceeds 1.0F. This lets loud sounds like explosions or withers travel farther than quiet clicks. Dimension gating uses theWorldServer.provider.getDimensionId so nether and overworld do not cross hear. The packet is S29PacketSoundEffect built from sound name, position, volume, and pitch. No exclusion applies, so even the causing player hears it. This contrasts with playSoundToNearExcept and the fixed 64.0D aux path.
/**
* Plays the specified sound. Arg: soundName, x, y, z, volume, pitch
*/
public void playSound(String soundName, double x, double y, double z, float volume, float pitch)
{
this.mcServer.getConfigurationManager().sendToAllNear(x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, this.theWorldServer.provider.getDimensionId(), new S29PacketSoundEffect(soundName, x, y, z, volume, pitch));
}
The comment documents soundName position volume pitch args. The method signature binds those plus coordinates. The single body line calls sendToAllNear with volume ternary for radius. The dimension ID arg gates by world. The S29PacketSoundEffect constructor packs name, coords, volume, pitch. This is inclusive broadcast with scaled 16.0D base radius.
Broadcast sound excluding one player.
This variant broadcasts the same named sound but excludes one originator player. It follows the identical volume-scaled radius rule as playSound. When volume is above 1.0F the radius becomes 16.0F times volume, otherwise fixed 16.0D. Recipients are resolved with sendToAllNearExcept passing the except EntityPlayer reference. Dimension gating again uses theWorldServer dimension ID to prevent cross-dimension hearing. The packet is S29PacketSoundEffect with identical sound name, x y z, volume, and pitch fields. This is used for player-caused sounds where the actor plays the sound locally or should not double hear. All other nearby players in range still receive it. The only difference from playSound is the exclusion filter.
/**
* Plays sound to all near players except the player reference given
*/
public void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch)
{
this.mcServer.getConfigurationManager().sendToAllNearExcept(except, x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, this.theWorldServer.provider.getDimensionId(), new S29PacketSoundEffect(soundName, x, y, z, volume, pitch));
}
The comment states the except-player behavior. The signature adds the except EntityPlayer first arg. The body mirrors playSound but calls sendToAllNearExcept. The ternary preserves 16.0D versus 16.0F times volume scaling. The S29PacketSoundEffect args are unchanged. This shows exclusion plus dimension-gated radius filtering.
Broadcast block auxiliary effect near position except actor.
This hook broadcasts a block auxiliary effect such as dispenser click or record break near a position. It excludes the triggering EntityPlayer passed in, so that player does not get a duplicate local effect. Recipients are resolved via sendToAllNearExcept with the block position coordinates. The radius is fixed at 64.0D regardless of volume, wider than the 16.0D base sound radius. Dimension gating uses theWorldServer dimension ID. The packet is S28PacketEffect constructed with sfxType, BlockPos, data, and false for non-global flag. The data field carries block ID or extra info depending on sfxType. This contrasts with broadcastSound which is global with true flag. Only players within 64 blocks in the same dimension receive it.
public void playRecord(String recordName, BlockPos blockPosIn)
{
}
public void playAuxSFX(EntityPlayer player, int sfxType, BlockPos blockPosIn, int data)
{
this.mcServer.getConfigurationManager().sendToAllNearExcept(player, (double)blockPosIn.getX(), (double)blockPosIn.getY(), (double)blockPosIn.getZ(), 64.0D, this.theWorldServer.provider.getDimensionId(), new S28PacketEffect(sfxType, blockPosIn, data, false));
}
The empty playRecord stub shows no networking for records here. The playAuxSFX signature binds actor, type, pos, and data. The body calls sendToAllNearExcept with 64.0D fixed radius and dimension gate. The S28PacketEffect is built with type, BlockPos, data, and false. The false flag marks it as ranged not global. This is exclusion plus fixed-radius fan-out.
Global broadcast of auxiliary effect to all players.
This method sends an auxiliary effect to every connected player with no range limit. It does not use sendToAllNear or any 16.0D or 64.0D or 512.0D radius check. It calls sendPacketToAllPlayers directly so all dimensions hear it unless client filters. The packet is S28PacketEffect built from soundID, BlockPos, data, and true for global flag. The true flag distinguishes it from playAuxSFX ranged effects. Typical uses are wither spawn, ender dragon death, or portal events that need world-wide awareness. Because there is no dimension gating, overworld players can receive nether-originated global events. No exclusion applies, so the trigger player also receives it. This is the loudest scope in WorldManager.
public void broadcastSound(int soundID, BlockPos pos, int data)
{
this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S28PacketEffect(soundID, pos, data, true));
}
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
{
for (EntityPlayerMP entityplayermp : this.mcServer.getConfigurationManager().getPlayerList())
{
}
The signature takes sound ID, position, and data. The single body line calls sendPacketToAllPlayers with no radius. The S28PacketEffect constructor uses true to mark global broadcast. The following lines reveal the start of sendBlockBreakProgress loop. This contrast shows global versus ranged S28 usage. No dimension or distance filtering occurs here.
Send crack animation to viewers within 32 blocks.
This method streams block cracking animation stages to nearby viewers. It loops over every EntityPlayerMP in the configuration manager player list. For each candidate it first checks worldObj identity equals theWorldServer to enforce dimension separation. It then skips the breaker entity ID itself so the miner does not receive their own crack echo. It computes dx dy dz from block pos to player posX posY posZ. It checks squared distance less than 1024.0D which equals 32 blocks. Only qualifiers get a direct S25PacketBlockBreakAnim via playerNetServerHandler.sendPacket. The packet carries breakerId, BlockPos, and progress 0 to 9 or negative to clear. Each progress change sends a fresh packet with no batching. This tight 32 block scope keeps digging visuals local.
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
{
for (EntityPlayerMP entityplayermp : this.mcServer.getConfigurationManager().getPlayerList())
{
if (entityplayermp != null && entityplayermp.worldObj == this.theWorldServer && entityplayermp.getEntityId() != breakerId)
{
double d0 = (double)pos.getX() - entityplayermp.posX;
double d1 = (double)pos.getY() - entityplayermp.posY;
double d2 = (double)pos.getZ() - entityplayermp.posZ;
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D)
{
entityplayermp.playerNetServerHandler.sendPacket(new S25PacketBlockBreakAnim(breakerId, pos, progress));
}
}
}
}
The signature binds breaker ID, position, and stage. The for loop iterates the global player list. The if filters null, same worldObj, and non-breaker ID. The dx dy dz lines compute offset for squared distance. The less than 1024.0D check gates to 32 blocks. The sendPacket line builds S25PacketBlockBreakAnim with ID, pos, and progress. This is manual per-player distance filtering.
Queue chunk block change for batched send.
This is the server hook that queues a block change for chunk-scoped delivery. On the client the sibling does render updates, but on the server it only flags the chunk. It delegates to theWorldServer.getPlayerManager with markBlockForUpdate and BlockPos. No packet is constructed or sent immediately here. PlayerManager maps the position to chunk XZ via right shift 4 and finds the PlayerInstance. That instance records local coordinates and defers the packet choice to onUpdate next tick. A single flagged block later becomes S23, two to sixty three become S22, and sixty four trigger S21 full chunk. Only players watching that chunk receive the eventual flush. This indirection enables per-tick batching instead of per-setBlock spam.
* On the client, re-renders all blocks in this range, inclusive. On the server, does nothing. Args: min x, min y,
* min z, max x, max y, max z
*/
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
{
}
public void markBlockForUpdate(BlockPos pos)
{
this.theWorldServer.getPlayerManager().markBlockForUpdate(pos);
}
The comment describes the client render range behavior. The empty markBlockRangeForRenderUpdate shows no server networking. The markBlockForUpdate signature takes only BlockPos. The body delegates to PlayerManager markBlockForUpdate. No radius or S23 S22 S21 construction appears here. This proves queuing is deferred to PlayerInstance onUpdate batching.
Register new entity with tracker for visibility.
This IWorldAccess callback registers a newly loaded or spawned entity for visibility tracking. It is invoked on all world accesses when an entity enters the world. On the server it calls theWorldServer.getEntityTracker with trackEntity and the entity. The tracker creates an EntityTrackerEntry that later emits the correct spawn packet per entity type. No packet is sent synchronously inside this method, so no radius like 512.0D applies yet. Viewer assignment uses tracking ranges configured per entity class. This is the entry point that eventually leads to spawn packet fan-out. Without this call clients would never learn about the entity. It complements onEntityRemoved which tears down tracking.
/**
* Called on all IWorldAccesses when an entity is created or loaded. On client worlds, starts downloading any
* necessary textures. On server worlds, adds the entity to the entity tracker.
*/
public void onEntityAdded(Entity entityIn)
{
this.theWorldServer.getEntityTracker().trackEntity(entityIn);
}
The comment contrasts client texture versus server tracker behavior. The method signature takes the new Entity. The single body line calls EntityTracker trackEntity. No packet constructor or radius appears inline. Tracking ranges are applied inside the tracker later. This shows deferred spawn fan-out via tracker entries.
Untrack entity and clear scoreboard state.
This callback tears down server visibility when an entity unloads or dies. It first calls theWorldServer.getEntityTracker with untrackEntity for the entity. That causes the tracker to send destroy packets and remove the entry from all viewers. It then calls theWorldServer.getScoreboard with func_181140_a to clear any scoreboard state tied to the entity. No distance radius governs removal because all current viewers must forget the entity. No explicit packet constructor appears here since destroy packets originate inside the tracker. This ensures clients do not retain ghost entities. It is the symmetric counterpart to onEntityAdded registration.
* Called on all IWorldAccesses when an entity is unloaded or destroyed. On client worlds, releases any downloaded
* textures. On server worlds, removes the entity from the entity tracker.
*/
public void onEntityRemoved(Entity entityIn)
{
this.theWorldServer.getEntityTracker().untrackEntity(entityIn);
this.theWorldServer.getScoreboard().func_181140_a(entityIn);
}
The comment describes unload versus destroy handling. The signature takes the removed Entity. The first body line calls untrackEntity to trigger destroy fan-out. The second line clears scoreboard objectives for that entity. No 16.0D or 64.0D check is present. Removal is broadcast to all prior viewers. This shows cleanup without direct packet code.
Packet Usage
| Packet | Dir | Trigger |
|---|---|---|
| S29 | sent | playSound or playSoundToNearExcept volume radius |
| S28 | sent | playAuxSFX 64.0D except or broadcastSound global |
| S25 | sent | sendBlockBreakProgress within 1024.0D |
| S23 | sent | markBlockForUpdate single-block flush via PlayerManager |
| S22 | sent | markBlockForUpdate multi-block flush via PlayerManager |
| S21 | sent | markBlockForUpdate full-chunk flush via PlayerManager |
Internal State
Related Vanilla Internals
Full Source
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
Deobfuscated MCP 1.8.9 source of WorldManager from Marcelektro/MavenMCP-1.8.9 (net/minecraft/world/WorldManager.java), stored verbatim.