    001    package net.minecraft.world;
    002
    003    import java.util.Iterator;
    004    import net.minecraft.entity.Entity;
    005    import net.minecraft.entity.player.EntityPlayer;
    006    import net.minecraft.entity.player.EntityPlayerMP;
    007    import net.minecraft.network.packet.Packet55BlockDestroy;
    008    import net.minecraft.network.packet.Packet61DoorChange;
    009    import net.minecraft.network.packet.Packet62LevelSound;
    010    import net.minecraft.server.MinecraftServer;
    011
    012    public 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        public void func_85102_a(EntityPlayer par1EntityPlayer, String par2Str, double par3, double par5, double par7, float par9, float par10)
    056        {
    057            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));
    058        }
    059
    060        /**
    061         * On the client, re-renders all blocks in this range, inclusive. On the server, does nothing. Args: min x, min y,
    062         * min z, max x, max y, max z
    063         */
    064        public void markBlockRangeForRenderUpdate(int par1, int par2, int par3, int par4, int par5, int par6) {}
    065
    066        /**
    067         * On the client, re-renders the block. On the server, sends the block to the client (which will re-render it),
    068         * including the tile entity description packet if applicable. Args: x, y, z
    069         */
    070        public void markBlockForUpdate(int par1, int par2, int par3)
    071        {
    072            this.theWorldServer.getPlayerManager().flagChunkForUpdate(par1, par2, par3);
    073        }
    074
    075        /**
    076         * On the client, re-renders this block. On the server, does nothing. Used for lighting updates.
    077         */
    078        public void markBlockForRenderUpdate(int par1, int par2, int par3) {}
    079
    080        /**
    081         * Plays the specified record. Arg: recordName, x, y, z
    082         */
    083        public void playRecord(String par1Str, int par2, int par3, int par4) {}
    084
    085        /**
    086         * Plays a pre-canned sound effect along with potentially auxiliary data-driven one-shot behaviour (particles, etc).
    087         */
    088        public void playAuxSFX(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6)
    089        {
    090            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));
    091        }
    092
    093        public void broadcastSound(int par1, int par2, int par3, int par4, int par5)
    094        {
    095            this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new Packet61DoorChange(par1, par2, par3, par4, par5, true));
    096        }
    097
    098        /**
    099         * Starts (or continues) destroying a block with given ID at the given coordinates for the given partially destroyed
    100         * value
    101         */
    102        public void destroyBlockPartially(int par1, int par2, int par3, int par4, int par5)
    103        {
    104            Iterator var6 = this.mcServer.getConfigurationManager().playerEntityList.iterator();
    105
    106            while (var6.hasNext())
    107            {
    108                EntityPlayerMP var7 = (EntityPlayerMP)var6.next();
    109
    110                if (var7 != null && var7.worldObj == this.theWorldServer && var7.entityId != par1)
    111                {
    112                    double var8 = (double)par2 - var7.posX;
    113                    double var10 = (double)par3 - var7.posY;
    114                    double var12 = (double)par4 - var7.posZ;
    115
    116                    if (var8 * var8 + var10 * var10 + var12 * var12 < 1024.0D)
    117                    {
    118                        var7.playerNetServerHandler.sendPacketToPlayer(new Packet55BlockDestroy(par1, par2, par3, par4, par5));
    119                    }
    120                }
    121            }
    122        }
    123    }