    001package net.minecraft.world;
    002
    003import java.util.Iterator;
    004import net.minecraft.entity.Entity;
    005import net.minecraft.entity.player.EntityPlayer;
    006import net.minecraft.entity.player.EntityPlayerMP;
    007import net.minecraft.network.packet.Packet55BlockDestroy;
    008import net.minecraft.network.packet.Packet61DoorChange;
    009import net.minecraft.network.packet.Packet62LevelSound;
    010import net.minecraft.server.MinecraftServer;
    011
    012public class WorldManager implements IWorldAccess
    013{
    014    /** Reference to the MinecraftServer object. */
    015    private MinecraftServer mcServer;
    016
    017    /** The WorldServer object. */
    018    private WorldServer theWorldServer;
    019
    020    public WorldManager(MinecraftServer par1MinecraftServer, WorldServer par2WorldServer)
    021    {
    022        this.mcServer = par1MinecraftServer;
    023        this.theWorldServer = par2WorldServer;
    024    }
    025
    026    /**
    027     * Spawns a particle. Arg: particleType, x, y, z, velX, velY, velZ
    028     */
    029    public void spawnParticle(String par1Str, double par2, double par4, double par6, double par8, double par10, double par12) {}
    030
    031    /**
    032     * Start the skin for this entity downloading, if necessary, and increment its reference counter
    033     */
    034    public void obtainEntitySkin(Entity par1Entity)
    035    {
    036        this.theWorldServer.getEntityTracker().addEntityToTracker(par1Entity);
    037    }
    038
    039    /**
    040     * Decrement the reference counter for this entity's skin image data
    041     */
    042    public void releaseEntitySkin(Entity par1Entity)
    043    {
    044        this.theWorldServer.getEntityTracker().removeEntityFromAllTrackingPlayers(par1Entity);
    045    }
    046
    047    /**
    048     * Plays the specified sound. Arg: soundName, x, y, z, volume, pitch
    049     */
    050    public void playSound(String par1Str, double par2, double par4, double par6, float par8, float par9)
    051    {
    052        this.mcServer.getConfigurationManager().sendToAllNear(par2, par4, par6, par8 > 1.0F ? (double)(16.0F * par8) : 16.0D, this.theWorldServer.provider.dimensionId, new Packet62LevelSound(par1Str, par2, par4, par6, par8, par9));
    053    }
    054
    055    /**
    056     * Plays sound to all near players except the player reference given
    057     */
    058    public void playSoundToNearExcept(EntityPlayer par1EntityPlayer, String par2Str, double par3, double par5, double par7, float par9, float par10)
    059    {
    060        this.mcServer.getConfigurationManager().sendToAllNearExcept(par1EntityPlayer, par3, par5, par7, par9 > 1.0F ? (double)(16.0F * par9) : 16.0D, this.theWorldServer.provider.dimensionId, new Packet62LevelSound(par2Str, par3, par5, par7, par9, par10));
    061    }
    062
    063    /**
    064     * On the client, re-renders all blocks in this range, inclusive. On the server, does nothing. Args: min x, min y,
    065     * min z, max x, max y, max z
    066     */
    067    public void markBlockRangeForRenderUpdate(int par1, int par2, int par3, int par4, int par5, int par6) {}
    068
    069    /**
    070     * On the client, re-renders the block. On the server, sends the block to the client (which will re-render it),
    071     * including the tile entity description packet if applicable. Args: x, y, z
    072     */
    073    public void markBlockForUpdate(int par1, int par2, int par3)
    074    {
    075        this.theWorldServer.getPlayerManager().flagChunkForUpdate(par1, par2, par3);
    076    }
    077
    078    /**
    079     * On the client, re-renders this block. On the server, does nothing. Used for lighting updates.
    080     */
    081    public void markBlockForRenderUpdate(int par1, int par2, int par3) {}
    082
    083    /**
    084     * Plays the specified record. Arg: recordName, x, y, z
    085     */
    086    public void playRecord(String par1Str, int par2, int par3, int par4) {}
    087
    088    /**
    089     * Plays a pre-canned sound effect along with potentially auxiliary data-driven one-shot behaviour (particles, etc).
    090     */
    091    public void playAuxSFX(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6)
    092    {
    093        this.mcServer.getConfigurationManager().sendToAllNearExcept(par1EntityPlayer, (double)par3, (double)par4, (double)par5, 64.0D, this.theWorldServer.provider.dimensionId, new Packet61DoorChange(par2, par3, par4, par5, par6, false));
    094    }
    095
    096    public void broadcastSound(int par1, int par2, int par3, int par4, int par5)
    097    {
    098        this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new Packet61DoorChange(par1, par2, par3, par4, par5, true));
    099    }
    100
    101    /**
    102     * Starts (or continues) destroying a block with given ID at the given coordinates for the given partially destroyed
    103     * value
    104     */
    105    public void destroyBlockPartially(int par1, int par2, int par3, int par4, int par5)
    106    {
    107        Iterator var6 = this.mcServer.getConfigurationManager().playerEntityList.iterator();
    108
    109        while (var6.hasNext())
    110        {
    111            EntityPlayerMP var7 = (EntityPlayerMP)var6.next();
    112
    113            if (var7 != null && var7.worldObj == this.theWorldServer && var7.entityId != par1)
    114            {
    115                double var8 = (double)par2 - var7.posX;
    116                double var10 = (double)par3 - var7.posY;
    117                double var12 = (double)par4 - var7.posZ;
    118
    119                if (var8 * var8 + var10 * var10 + var12 * var12 < 1024.0D)
    120                {
    121                    var7.playerNetServerHandler.sendPacketToPlayer(new Packet55BlockDestroy(par1, par2, par3, par4, par5));
    122                }
    123            }
    124        }
    125    }
    126}