WorldManager .java

net.minecraft.world.WorldManager (class): members: theWorldServer, broadcastSound, markBlockRangeForRenderUpdate, sendBlockBreakProgress, notifyLightSet.

net.minecraft.worldclass114 linescommon4.5 KB

Implements

API Surface (12)

void spawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int... parameters)
void onEntityAdded(Entity entityIn)
void onEntityRemoved(Entity entityIn)
void playSound(String soundName, double x, double y, double z, float volume, float pitch)
void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch)
void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
void markBlockForUpdate(BlockPos pos)
void notifyLightSet(BlockPos pos)
void playRecord(String recordName, BlockPos blockPosIn)
void playAuxSFX(EntityPlayer player, int sfxType, BlockPos blockPosIn, int data)
void broadcastSound(int soundID, BlockPos pos, int data)
void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)

Fields & Constants (2)

mcServer
theWorldServer

Full Source

WorldManager.java114 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world;
2
3
import net.minecraft.entity.Entity;
4
import net.minecraft.entity.player.EntityPlayer;
5
import net.minecraft.entity.player.EntityPlayerMP;
6
import net.minecraft.network.play.server.S25PacketBlockBreakAnim;
7
import net.minecraft.network.play.server.S28PacketEffect;
8
import net.minecraft.network.play.server.S29PacketSoundEffect;
9
import net.minecraft.server.MinecraftServer;
10
import net.minecraft.util.BlockPos;
11
12
public class WorldManager implements IWorldAccess
13
{
14
    /** Reference to the MinecraftServer object. */
15
    private MinecraftServer mcServer;
16
17
    /** The WorldServer object. */
18
    private WorldServer theWorldServer;
19
20
    public WorldManager(MinecraftServer mcServerIn, WorldServer worldServerIn)
21
    {
22
        this.mcServer = mcServerIn;
23
        this.theWorldServer = worldServerIn;
24
    }
25
26
    public void spawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int... parameters)
27
    {
28
    }
29
30
    /**
31
     * Called on all IWorldAccesses when an entity is created or loaded. On client worlds, starts downloading any
32
     * necessary textures. On server worlds, adds the entity to the entity tracker.
33
     */
34
    public void onEntityAdded(Entity entityIn)
35
    {
36
        this.theWorldServer.getEntityTracker().trackEntity(entityIn);
37
    }
38
39
    /**
40
     * Called on all IWorldAccesses when an entity is unloaded or destroyed. On client worlds, releases any downloaded
41
     * textures. On server worlds, removes the entity from the entity tracker.
42
     */
43
    public void onEntityRemoved(Entity entityIn)
44
    {
45
        this.theWorldServer.getEntityTracker().untrackEntity(entityIn);
46
        this.theWorldServer.getScoreboard().func_181140_a(entityIn);
47
    }
48
49
    /**
50
     * Plays the specified sound. Arg: soundName, x, y, z, volume, pitch
51
     */
52
    public void playSound(String soundName, double x, double y, double z, float volume, float pitch)
53
    {
54
        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));
55
    }
56
57
    /**
58
     * Plays sound to all near players except the player reference given
59
     */
60
    public void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch)
61
    {
62
        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));
63
    }
64
65
    /**
66
     * On the client, re-renders all blocks in this range, inclusive. On the server, does nothing. Args: min x, min y,
67
     * min z, max x, max y, max z
68
     */
69
    public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
70
    {
71
    }
72
73
    public void markBlockForUpdate(BlockPos pos)
74
    {
75
        this.theWorldServer.getPlayerManager().markBlockForUpdate(pos);
76
    }
77
78
    public void notifyLightSet(BlockPos pos)
79
    {
80
    }
81
82
    public void playRecord(String recordName, BlockPos blockPosIn)
83
    {
84
    }
85
86
    public void playAuxSFX(EntityPlayer player, int sfxType, BlockPos blockPosIn, int data)
87
    {
88
        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));
89
    }
90
91
    public void broadcastSound(int soundID, BlockPos pos, int data)
92
    {
93
        this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S28PacketEffect(soundID, pos, data, true));
94
    }
95
96
    public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
97
    {
98
        for (EntityPlayerMP entityplayermp : this.mcServer.getConfigurationManager().getPlayerList())
99
        {
100
            if (entityplayermp != null && entityplayermp.worldObj == this.theWorldServer && entityplayermp.getEntityId() != breakerId)
101
            {
102
                double d0 = (double)pos.getX() - entityplayermp.posX;
103
                double d1 = (double)pos.getY() - entityplayermp.posY;
104
                double d2 = (double)pos.getZ() - entityplayermp.posZ;
105
106
                if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D)
107
                {
108
                    entityplayermp.playerNetServerHandler.sendPacket(new S25PacketBlockBreakAnim(breakerId, pos, progress));
109
                }
110
            }
111
        }
112
    }
113
}
114

Deobfuscated MCP 1.8.9 source of WorldManager from Marcelektro/MavenMCP-1.8.9 (net/minecraft/world/WorldManager.java), stored verbatim.