Beispiel #1
0
        /// <summary>
        /// Adds an entity to the chunk. Args: entity
        /// </summary>
        public virtual void AddEntity(Entity par1Entity)
        {
            HasEntities = true;
            int i = MathHelper2.Floor_double(par1Entity.PosX / 16D);
            int j = MathHelper2.Floor_double(par1Entity.PosZ / 16D);

            if (i != XPosition || j != ZPosition)
            {
                Console.WriteLine((new StringBuilder()).Append("Wrong location! ").Append(par1Entity).ToString());
                //Thread.DumpStack();
            }

            int k = MathHelper2.Floor_double(par1Entity.PosY / 16D);

            if (k < 0)
            {
                k = 0;
            }

            if (k >= EntityLists.Length)
            {
                k = EntityLists.Length - 1;
            }

            par1Entity.AddedToChunk = true;
            par1Entity.ChunkCoordX  = XPosition;
            par1Entity.ChunkCoordY  = k;
            par1Entity.ChunkCoordZ  = ZPosition;
            EntityLists[k].Add(par1Entity);
        }
        /// <summary>
        /// Called when the block is placed in the world.
        /// </summary>
        public override void OnBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
        {
            int i = MathHelper2.Floor_double((double)((par5EntityLiving.RotationYaw * 4F) / 360F) + 0.5D) & 3;
            int j = par1World.GetBlockMetadata(par2, par3, par4) & 4;

            if (i == 0)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, 2 | j);
            }

            if (i == 1)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, 1 | j);
            }

            if (i == 2)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, 3 | j);
            }

            if (i == 3)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, 0 | j);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            if (!TheWorld.IsDaytime())
            {
                return(false);
            }

            if (!TheCreature.IsBurning())
            {
                return(false);
            }

            if (!TheWorld.CanBlockSeeTheSky(MathHelper2.Floor_double(TheCreature.PosX), (int)TheCreature.BoundingBox.MinY, MathHelper2.Floor_double(TheCreature.PosZ)))
            {
                return(false);
            }

            Vec3D vec3d = FindPossibleShelter();

            if (vec3d == null)
            {
                return(false);
            }
            else
            {
                ShelterX = vec3d.XCoord;
                ShelterY = vec3d.YCoord;
                ShelterZ = vec3d.ZCoord;
                return(true);
            }
        }
        /// <summary>
        /// Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
        /// use this to react to sunlight and start to burn.
        /// </summary>
        public override void OnLivingUpdate()
        {
            base.OnLivingUpdate();

            if (Field_48120_c > 0)
            {
                Field_48120_c--;
            }

            if (Field_48118_d > 0)
            {
                Field_48118_d--;
            }

            //JAVA TO C# CONVERTER TODO TASK: Octal literals cannot be represented in C#:
            if (MotionX * MotionX + MotionZ * MotionZ > 2.5000002779052011E-007D && Rand.Next(5) == 0)
            {
                int i = MathHelper2.Floor_double(PosX);
                int j = MathHelper2.Floor_double(PosY - 0.20000000298023224D - (double)YOffset);
                int k = MathHelper2.Floor_double(PosZ);
                int l = WorldObj.GetBlockId(i, j, k);

                if (l > 0)
                {
                    WorldObj.SpawnParticle((new StringBuilder()).Append("tilecrack_").Append(l).ToString(), PosX + ((double)Rand.NextFloat() - 0.5D) * (double)Width, BoundingBox.MinY + 0.10000000000000001D, PosZ + ((double)Rand.NextFloat() - 0.5D) * (double)Width, 4D * ((double)Rand.NextFloat() - 0.5D), 0.5D, ((double)Rand.NextFloat() - 0.5D) * 4D);
                }
            }
        }
        /// <summary>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            if (VillagerObj.GetGrowingAge() != 0)
            {
                return(false);
            }

            if (VillagerObj.GetRNG().Next(500) != 0)
            {
                return(false);
            }

            VillageObj = WorldObj.VillageCollectionObj.FindNearestVillage(MathHelper2.Floor_double(VillagerObj.PosX), MathHelper2.Floor_double(VillagerObj.PosY), MathHelper2.Floor_double(VillagerObj.PosZ), 0);

            if (VillageObj == null)
            {
                return(false);
            }

            if (!CheckSufficientDoorsPresentForNewVillager())
            {
                return(false);
            }

            Entity entity = WorldObj.FindNearestEntityWithinAABB(typeof(net.minecraft.src.EntityVillager), VillagerObj.BoundingBox.Expand(8, 3, 8), VillagerObj);

            if (entity == null)
            {
                return(false);
            }

            Mate = (EntityVillager)entity;
            return(Mate.GetGrowingAge() == 0);
        }
        public virtual void OnUpdateMoveHelper()
        {
            Entity.SetMoveForward(0.0F);

            if (!Field_46036_f)
            {
                return;
            }

            Field_46036_f = false;
            int    i  = MathHelper2.Floor_double(Entity.BoundingBox.MinY + 0.5D);
            double d  = PosX - Entity.PosX;
            double d1 = PosZ - Entity.PosZ;
            double d2 = PosY - (double)i;
            double d3 = d * d + d2 * d2 + d1 * d1;

            //JAVA TO C# CONVERTER TODO TASK: Octal literals cannot be represented in C#:
            if (d3 < 2.5000002779052011E-007D)
            {
                return;
            }

            float f = (float)((Math.Atan2(d1, d) * 180D) / Math.PI) - 90F;

            Entity.RotationYaw = Func_48185_a(Entity.RotationYaw, f, 30F);
            Entity.Func_48098_g(Speed);

            if (d2 > 0.0F && d * d + d1 * d1 < 1.0D)
            {
                Entity.GetJumpHelper().SetJumping();
            }
        }
Beispiel #7
0
        /// <summary>
        /// Updates the task
        /// </summary>
        public override void UpdateTask()
        {
            EatGrassTick = Math.Max(0, EatGrassTick - 1);

            if (EatGrassTick != 4)
            {
                return;
            }

            int i = MathHelper2.Floor_double(TheEntity.PosX);
            int j = MathHelper2.Floor_double(TheEntity.PosY);
            int k = MathHelper2.Floor_double(TheEntity.PosZ);

            if (TheWorld.GetBlockId(i, j, k) == Block.TallGrass.BlockID)
            {
                TheWorld.PlayAuxSFX(2001, i, j, k, Block.TallGrass.BlockID + 4096);
                TheWorld.SetBlockWithNotify(i, j, k, 0);
                TheEntity.EatGrassBonus();
            }
            else if (TheWorld.GetBlockId(i, j - 1, k) == Block.Grass.BlockID)
            {
                TheWorld.PlayAuxSFX(2001, i, j - 1, k, Block.Grass.BlockID);
                TheWorld.SetBlockWithNotify(i, j - 1, k, Block.Dirt.BlockID);
                TheEntity.EatGrassBonus();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Caches the current frame's active render info, including the current World, RenderEngine, GameSettings and
        /// FontRenderer settings, as well as interpolated player position, pitch and yaw.
        /// </summary>
        public virtual void CacheActiveRenderInfo(World par1World, RenderEngine par2RenderEngine, FontRenderer par3FontRenderer, EntityLiving par4EntityLiving, GameSettings par5GameSettings, float par6)
        {
            WorldObj     = par1World;
            RenderEngine = par2RenderEngine;
            Options      = par5GameSettings;
            LivingPlayer = par4EntityLiving;
            FontRenderer = par3FontRenderer;

            if (par4EntityLiving.IsPlayerSleeping())
            {
                int i = par1World.GetBlockId(MathHelper2.Floor_double(par4EntityLiving.PosX), MathHelper2.Floor_double(par4EntityLiving.PosY), MathHelper2.Floor_double(par4EntityLiving.PosZ));

                if (i == Block.Bed.BlockID)
                {
                    int j = par1World.GetBlockMetadata(MathHelper2.Floor_double(par4EntityLiving.PosX), MathHelper2.Floor_double(par4EntityLiving.PosY), MathHelper2.Floor_double(par4EntityLiving.PosZ));
                    int k = j & 3;
                    PlayerViewY = k * 90 + 180;
                    PlayerViewX = 0.0F;
                }
            }
            else
            {
                PlayerViewY = par4EntityLiving.PrevRotationYaw + (par4EntityLiving.RotationYaw - par4EntityLiving.PrevRotationYaw) * par6;
                PlayerViewX = par4EntityLiving.PrevRotationPitch + (par4EntityLiving.RotationPitch - par4EntityLiving.PrevRotationPitch) * par6;
            }

            if (par5GameSettings.ThirdPersonView == 2)
            {
                PlayerViewY += 180F;
            }

            Field_1222_l = par4EntityLiving.LastTickPosX + (par4EntityLiving.PosX - par4EntityLiving.LastTickPosX) * (double)par6;
            Field_1221_m = par4EntityLiving.LastTickPosY + (par4EntityLiving.PosY - par4EntityLiving.LastTickPosY) * (double)par6;
            Field_1220_n = par4EntityLiving.LastTickPosZ + (par4EntityLiving.PosZ - par4EntityLiving.LastTickPosZ) * (double)par6;
        }
Beispiel #9
0
        /// <summary>
        /// The actual render method that is used in doRender
        /// </summary>
        public virtual void DoRenderFallingSand(EntityFallingSand par1EntityFallingSand, double par2, double par4, double par6, float par8, float par9)
        {
            //GL.PushMatrix();
            //GL.Translate((float)par2, (float)par4, (float)par6);
            LoadTexture("/terrain.png");
            Block block = Block.BlocksList[par1EntityFallingSand.BlockID];
            World world = par1EntityFallingSand.GetWorld();

            //GL.Disable(EnableCap.Lighting);

            if (block == Block.DragonEgg)
            {
                RenderBlocks.BlockAccess = world;
                Tessellator tessellator = Tessellator.Instance;
                tessellator.StartDrawingQuads();
                tessellator.SetTranslation((float)(-MathHelper2.Floor_double(par1EntityFallingSand.PosX)) - 0.5F, (float)(-MathHelper2.Floor_double(par1EntityFallingSand.PosY)) - 0.5F, (float)(-MathHelper2.Floor_double(par1EntityFallingSand.PosZ)) - 0.5F);
                RenderBlocks.RenderBlockByRenderType(block, MathHelper2.Floor_double(par1EntityFallingSand.PosX), MathHelper2.Floor_double(par1EntityFallingSand.PosY), MathHelper2.Floor_double(par1EntityFallingSand.PosZ));
                tessellator.SetTranslation(0.0F, 0.0F, 0.0F);
                tessellator.Draw();
            }
            else
            {
                RenderBlocks.RenderBlockFallingSand(block, world, MathHelper2.Floor_double(par1EntityFallingSand.PosX), MathHelper2.Floor_double(par1EntityFallingSand.PosY), MathHelper2.Floor_double(par1EntityFallingSand.PosZ));
            }

            //GL.Enable(EnableCap.Lighting);
            //GL.PopMatrix();
        }
        private VillageDoorInfo Func_48284_a(Village par1Village)
        {
            VillageDoorInfo               villagedoorinfo = null;
            int                           i        = 0x7fffffff;
            List <VillageDoorInfo>        list     = par1Village.GetVillageDoorInfoList();
            IEnumerator <VillageDoorInfo> iterator = list.GetEnumerator();

            do
            {
                if (!iterator.MoveNext())
                {
                    break;
                }

                VillageDoorInfo villagedoorinfo1 = iterator.Current;
                int             j = villagedoorinfo1.GetDistanceSquared(MathHelper2.Floor_double(TheEntity.PosX), MathHelper2.Floor_double(TheEntity.PosY), MathHelper2.Floor_double(TheEntity.PosZ));

                if (j < i && !Func_48285_a(villagedoorinfo1))
                {
                    villagedoorinfo = villagedoorinfo1;
                    i = j;
                }
            }while (true);

            return(villagedoorinfo);
        }
Beispiel #11
0
        /// <summary>
        /// Time remaining during which the Animal is sped up and flees.
        /// </summary>
        protected virtual void UpdateWanderPath()
        {
            Profiler.StartSection("stroll");
            bool  flag = false;
            int   i    = -1;
            int   j    = -1;
            int   k    = -1;
            float f    = -99999F;

            for (int l = 0; l < 10; l++)
            {
                int   i1 = MathHelper2.Floor_double((PosX + (double)Rand.Next(13)) - 6D);
                int   j1 = MathHelper2.Floor_double((PosY + (double)Rand.Next(7)) - 3D);
                int   k1 = MathHelper2.Floor_double((PosZ + (double)Rand.Next(13)) - 6D);
                float f1 = GetBlockPathWeight(i1, j1, k1);

                if (f1 > f)
                {
                    f    = f1;
                    i    = i1;
                    j    = j1;
                    k    = k1;
                    flag = true;
                }
            }

            if (flag)
            {
                PathToEntity = WorldObj.GetEntityPathToXYZ(this, i, j, k, 10F, true, false, false, true);
            }

            Profiler.EndSection();
        }
Beispiel #12
0
        public EntityLightningBolt(World par1World, float par2, float par4, float par6)
            : base(par1World)
        {
            BoltVertex = 0L;
            SetLocationAndAngles(par2, par4, par6, 0.0F, 0.0F);
            LightningState = 2;
            BoltVertex     = Rand.Next();
            BoltLivingTime = Rand.Next(3) + 1;

            if (par1World.DifficultySetting >= 2 && par1World.DoChunksNearChunkExist(MathHelper2.Floor_double(par2), MathHelper2.Floor_double(par4), MathHelper2.Floor_double(par6), 10))
            {
                int i  = MathHelper2.Floor_double(par2);
                int k  = MathHelper2.Floor_double(par4);
                int i1 = MathHelper2.Floor_double(par6);

                if (par1World.GetBlockId(i, k, i1) == 0 && Block.Fire.CanPlaceBlockAt(par1World, i, k, i1))
                {
                    par1World.SetBlockWithNotify(i, k, i1, Block.Fire.BlockID);
                }

                for (int j = 0; j < 4; j++)
                {
                    int l  = (MathHelper2.Floor_double(par2) + Rand.Next(3)) - 1;
                    int j1 = (MathHelper2.Floor_double(par4) + Rand.Next(3)) - 1;
                    int k1 = (MathHelper2.Floor_double(par6) + Rand.Next(3)) - 1;

                    if (par1World.GetBlockId(l, j1, k1) == 0 && Block.Fire.CanPlaceBlockAt(par1World, l, j1, k1))
                    {
                        par1World.SetBlockWithNotify(l, j1, k1, Block.Fire.BlockID);
                    }
                }
            }
        }
        public override void RenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
        {
            float f = ((float)Age + par2) / (float)MaxAge;

            f *= f;
            double d  = EntityToPickUp.PosX;
            double d1 = EntityToPickUp.PosY;
            double d2 = EntityToPickUp.PosZ;
            double d3 = EntityPickingUp.LastTickPosX + (EntityPickingUp.PosX - EntityPickingUp.LastTickPosX) * (double)par2;
            double d4 = EntityPickingUp.LastTickPosY + (EntityPickingUp.PosY - EntityPickingUp.LastTickPosY) * (double)par2 + (double)YOffs;
            double d5 = EntityPickingUp.LastTickPosZ + (EntityPickingUp.PosZ - EntityPickingUp.LastTickPosZ) * (double)par2;
            double d6 = d + (d3 - d) * (double)f;
            double d7 = d1 + (d4 - d1) * (double)f;
            double d8 = d2 + (d5 - d2) * (double)f;
            int    i  = MathHelper2.Floor_double(d6);
            int    j  = MathHelper2.Floor_double(d7 + (double)(YOffset / 2.0F));
            int    k  = MathHelper2.Floor_double(d8);
            int    l  = GetBrightnessForRender(par2);
            int    i1 = l % 0x10000;
            int    j1 = l / 0x10000;

            OpenGlHelper.SetLightmapTextureCoords(OpenGlHelper.LightmapTexUnit, (float)i1 / 1.0F, (float)j1 / 1.0F);
            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
            d6 -= InterpPosX;
            d7 -= InterpPosY;
            d8 -= InterpPosZ;
            RenderManager.Instance.RenderEntityWithPosYaw(EntityToPickUp, (float)d6, (float)d7, (float)d8, EntityToPickUp.RotationYaw, par2);
        }
Beispiel #14
0
        /// <summary>
        /// Checks if the entity's current position is a valid location to spawn this entity.
        /// </summary>
        public override bool GetCanSpawnHere()
        {
            if (WorldObj.Rand.Next(3) == 0)
            {
                return(false);
            }

            if (WorldObj.CheckIfAABBIsClear(BoundingBox) && WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox))
            {
                int i = MathHelper2.Floor_double(PosX);
                int j = MathHelper2.Floor_double(BoundingBox.MinY);
                int k = MathHelper2.Floor_double(PosZ);

                if (j < 63)
                {
                    return(false);
                }

                int l = WorldObj.GetBlockId(i, j - 1, k);

                if (l == Block.Grass.BlockID || l == Block.Leaves.BlockID)
                {
                    return(true);
                }
            }

            return(false);
        }
        private void Func_160_a(EntityPainting par1EntityPainting, float par2, float par3)
        {
            int i = MathHelper2.Floor_double(par1EntityPainting.PosX);
            int j = MathHelper2.Floor_double(par1EntityPainting.PosY + (double)(par3 / 16F));
            int k = MathHelper2.Floor_double(par1EntityPainting.PosZ);

            if (par1EntityPainting.Direction == 0)
            {
                i = MathHelper2.Floor_double(par1EntityPainting.PosX + (double)(par2 / 16F));
            }

            if (par1EntityPainting.Direction == 1)
            {
                k = MathHelper2.Floor_double(par1EntityPainting.PosZ - (double)(par2 / 16F));
            }

            if (par1EntityPainting.Direction == 2)
            {
                i = MathHelper2.Floor_double(par1EntityPainting.PosX - (double)(par2 / 16F));
            }

            if (par1EntityPainting.Direction == 3)
            {
                k = MathHelper2.Floor_double(par1EntityPainting.PosZ + (double)(par2 / 16F));
            }

            int l  = RenderManager.WorldObj.GetLightBrightnessForSkyBlocks(i, j, k, 0);
            int i1 = l % 0x10000;
            int j1 = l / 0x10000;

            OpenGlHelper.SetLightmapTextureCoords(OpenGlHelper.LightmapTexUnit, i1, j1);
            //GL.Color3(1.0F, 1.0F, 1.0F);
        }
Beispiel #16
0
        public override void RenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
        {
            float f = ((float)Field_27018_a + par2) / (float)Field_27020_o;

            f *= f;
            float f1 = 2.0F - f * 2.0F;

            if (f1 > 1.0F)
            {
                f1 = 1.0F;
            }

            f1 *= 0.2F;
            //GL.Disable(EnableCap.Lighting);
            float f2 = 0.125F;
            float f3 = (float)(PosX - InterpPosX);
            float f4 = (float)(PosY - InterpPosY);
            float f5 = (float)(PosZ - InterpPosZ);
            float f6 = WorldObj.GetLightBrightness(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ));

            //CurrentFootSteps.BindTexture(CurrentFootSteps.GetTexture("/misc/footprint.png"));
            CurrentFootSteps.BindTexture("misc.footprint.png");
            //GL.Enable(EnableCap.Blend);
            //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            par1Tessellator.StartDrawingQuads();
            par1Tessellator.SetColorRGBA_F(f6, f6, f6, f1);
            par1Tessellator.AddVertexWithUV(f3 - f2, f4, f5 + f2, 0.0F, 1.0D);
            par1Tessellator.AddVertexWithUV(f3 + f2, f4, f5 + f2, 1.0D, 1.0D);
            par1Tessellator.AddVertexWithUV(f3 + f2, f4, f5 - f2, 1.0D, 0.0F);
            par1Tessellator.AddVertexWithUV(f3 - f2, f4, f5 - f2, 0.0F, 0.0F);
            par1Tessellator.Draw();
            //GL.Disable(EnableCap.Blend);
            //GL.Enable(EnableCap.Lighting);
        }
Beispiel #17
0
        /// <summary>
        /// Checks if the entity's current position is a valid location to spawn this entity.
        /// </summary>
        public override bool GetCanSpawnHere()
        {
            int i = MathHelper2.Floor_double(PosX);
            int j = MathHelper2.Floor_double(BoundingBox.MinY);
            int k = MathHelper2.Floor_double(PosZ);

            return(base.GetCanSpawnHere() && GetBlockPathWeight(i, j, k) >= 0.0F);
        }
Beispiel #18
0
 public Packet26EntityExpOrb(EntityXPOrb par1EntityXPOrb)
 {
     EntityId = par1EntityXPOrb.EntityId;
     PosX     = MathHelper2.Floor_double(par1EntityXPOrb.PosX * 32D);
     PosY     = MathHelper2.Floor_double(par1EntityXPOrb.PosY * 32D);
     PosZ     = MathHelper2.Floor_double(par1EntityXPOrb.PosZ * 32D);
     XpValue  = par1EntityXPOrb.GetXpValue();
 }
        /// <summary>
        /// Checks if the entity's current position is a valid location to spawn this entity.
        /// </summary>
        public override bool GetCanSpawnHere()
        {
            int i = MathHelper2.Floor_double(PosX);
            int j = MathHelper2.Floor_double(BoundingBox.MinY);
            int k = MathHelper2.Floor_double(PosZ);

            return(WorldObj.GetBlockId(i, j - 1, k) == Block.Grass.BlockID && WorldObj.GetFullBlockLightValue(i, j, k) > 8 && base.GetCanSpawnHere());
        }
        public override bool Generate(World par1World, Random par2Random, int par3, int par4, int par5)
        {
            float  f  = par2Random.NextFloat() * (float)Math.PI;
            double d  = (float)(par3 + 8) + (MathHelper2.Sin(f) * (float)NumberOfBlocks) / 8F;
            double d1 = (float)(par3 + 8) - (MathHelper2.Sin(f) * (float)NumberOfBlocks) / 8F;
            double d2 = (float)(par5 + 8) + (MathHelper2.Cos(f) * (float)NumberOfBlocks) / 8F;
            double d3 = (float)(par5 + 8) - (MathHelper2.Cos(f) * (float)NumberOfBlocks) / 8F;
            double d4 = (par4 + par2Random.Next(3)) - 2;
            double d5 = (par4 + par2Random.Next(3)) - 2;

            for (int i = 0; i <= NumberOfBlocks; i++)
            {
                double d6  = d + ((d1 - d) * (double)i) / (double)NumberOfBlocks;
                double d7  = d4 + ((d5 - d4) * (double)i) / (double)NumberOfBlocks;
                double d8  = d2 + ((d3 - d2) * (double)i) / (double)NumberOfBlocks;
                double d9  = (par2Random.NextDouble() * (double)NumberOfBlocks) / 16D;
                double d10 = (double)(MathHelper2.Sin(((float)i * (float)Math.PI) / (float)NumberOfBlocks) + 1.0F) * d9 + 1.0D;
                double d11 = (double)(MathHelper2.Sin(((float)i * (float)Math.PI) / (float)NumberOfBlocks) + 1.0F) * d9 + 1.0D;
                int    j   = MathHelper2.Floor_double(d6 - d10 / 2D);
                int    k   = MathHelper2.Floor_double(d7 - d11 / 2D);
                int    l   = MathHelper2.Floor_double(d8 - d10 / 2D);
                int    i1  = MathHelper2.Floor_double(d6 + d10 / 2D);
                int    j1  = MathHelper2.Floor_double(d7 + d11 / 2D);
                int    k1  = MathHelper2.Floor_double(d8 + d10 / 2D);

                for (int l1 = j; l1 <= i1; l1++)
                {
                    double d12 = (((double)l1 + 0.5D) - d6) / (d10 / 2D);

                    if (d12 * d12 >= 1.0D)
                    {
                        continue;
                    }

                    for (int i2 = k; i2 <= j1; i2++)
                    {
                        double d13 = (((double)i2 + 0.5D) - d7) / (d11 / 2D);

                        if (d12 * d12 + d13 * d13 >= 1.0D)
                        {
                            continue;
                        }

                        for (int j2 = l; j2 <= k1; j2++)
                        {
                            double d14 = (((double)j2 + 0.5D) - d8) / (d10 / 2D);

                            if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && par1World.GetBlockId(l1, i2, j2) == Block.Stone.BlockID)
                            {
                                par1World.SetBlock(l1, i2, j2, MinableBlockId);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #21
0
 public Packet34EntityTeleport(Entity par1Entity)
 {
     EntityId  = par1Entity.EntityId;
     XPosition = MathHelper2.Floor_double(par1Entity.PosX * 32D);
     YPosition = MathHelper2.Floor_double(par1Entity.PosY * 32D);
     ZPosition = MathHelper2.Floor_double(par1Entity.PosZ * 32D);
     Yaw       = (sbyte)(int)((par1Entity.RotationYaw * 256F) / 360F);
     Pitch     = (sbyte)(int)((par1Entity.RotationPitch * 256F) / 360F);
 }
Beispiel #22
0
        /// <summary>
        /// Renders all the overlays that are in first person mode. Args: partialTickTime
        /// </summary>
        public virtual void RenderOverlays(float par1)
        {
            //GL.Disable(EnableCap.AlphaTest);

            if (Mc.ThePlayer.IsBurning())
            {
                int i = Mc.RenderEngineOld.GetTexture("/terrain.png");
                //GL.BindTexture(TextureTarget.Texture2D, i);
                RenderFireInFirstPerson(par1);
            }

            if (Mc.ThePlayer.IsEntityInsideOpaqueBlock())
            {
                int j  = MathHelper2.Floor_double(Mc.ThePlayer.PosX);
                int l  = MathHelper2.Floor_double(Mc.ThePlayer.PosY);
                int i1 = MathHelper2.Floor_double(Mc.ThePlayer.PosZ);
                int j1 = Mc.RenderEngineOld.GetTexture("/terrain.png");
                //GL.BindTexture(TextureTarget.Texture2D, j1);
                int k1 = Mc.TheWorld.GetBlockId(j, l, i1);

                if (Mc.TheWorld.IsBlockNormalCube(j, l, i1))
                {
                    RenderInsideOfBlock(par1, Block.BlocksList[k1].GetBlockTextureFromSide(2));
                }
                else
                {
                    for (int l1 = 0; l1 < 8; l1++)
                    {
                        float f  = ((float)((l1 >> 0) % 2) - 0.5F) * Mc.ThePlayer.Width * 0.9F;
                        float f1 = ((float)((l1 >> 1) % 2) - 0.5F) * Mc.ThePlayer.Height * 0.2F;
                        float f2 = ((float)((l1 >> 2) % 2) - 0.5F) * Mc.ThePlayer.Width * 0.9F;
                        int   i2 = MathHelper2.Floor_float((float)j + f);
                        int   j2 = MathHelper2.Floor_float((float)l + f1);
                        int   k2 = MathHelper2.Floor_float((float)i1 + f2);

                        if (Mc.TheWorld.IsBlockNormalCube(i2, j2, k2))
                        {
                            k1 = Mc.TheWorld.GetBlockId(i2, j2, k2);
                        }
                    }
                }

                if (Block.BlocksList[k1] != null)
                {
                    RenderInsideOfBlock(par1, Block.BlocksList[k1].GetBlockTextureFromSide(2));
                }
            }

            if (Mc.ThePlayer.IsInsideOfMaterial(Material.Water))
            {
                int k = Mc.RenderEngineOld.GetTexture("/misc/water.png");
                //GL.BindTexture(TextureTarget.Texture2D, k);
                RenderWarpedTextureOverlay(par1);
            }

            //GL.Enable(EnableCap.AlphaTest);
        }
 /// <summary>
 /// Returns the path to the given coordinates
 /// </summary>
 public virtual PathEntity GetPathToXYZ(double par1, double par3, double par5)
 {
     if (!CanNavigate())
     {
         return(null);
     }
     else
     {
         return(WorldObj.GetEntityPathToXYZ(TheEntity, MathHelper2.Floor_double(par1), (int)par3, MathHelper2.Floor_double(par5), PathSearchRange, CanPassOpenWoodenDoors, CanPassClosedWoodenDoors, AvoidsWater, CanSwim));
     }
 }
Beispiel #24
0
        public virtual Vec3D Func_515_a(double par1, double par3, double par5, double par7)
        {
            int i = MathHelper2.Floor_double(par1);
            int j = MathHelper2.Floor_double(par3);
            int k = MathHelper2.Floor_double(par5);

            if (BlockRail.IsRailBlockAt(WorldObj, i, j - 1, k))
            {
                j--;
            }

            int l = WorldObj.GetBlockId(i, j, k);

            if (BlockRail.IsRailBlock(l))
            {
                int i1 = WorldObj.GetBlockMetadata(i, j, k);

                if (((BlockRail)Block.BlocksList[l]).IsPowered())
                {
                    i1 &= 7;
                }

                par3 = j;

                if (i1 >= 2 && i1 <= 5)
                {
                    par3 = j + 1;
                }

                int[][] ai = Field_855_j[i1];
                float   d  = ai[1][0] - ai[0][0];
                float   d1 = ai[1][2] - ai[0][2];
                float   d2 = (float)Math.Sqrt(d * d + d1 * d1);
                d    /= d2;
                d1   /= d2;
                par1 += d * par7;
                par5 += d1 * par7;

                if (ai[0][1] != 0 && MathHelper2.Floor_double(par1) - i == ai[0][0] && MathHelper2.Floor_double(par5) - k == ai[0][2])
                {
                    par3 += ai[0][1];
                }
                else if (ai[1][1] != 0 && MathHelper2.Floor_double(par1) - i == ai[1][0] && MathHelper2.Floor_double(par5) - k == ai[1][2])
                {
                    par3 += ai[1][1];
                }

                return(Func_514_g(par1, par3, par5));
            }
            else
            {
                return(null);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Called when the block is placed in the world.
        /// </summary>
        public override void OnBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
        {
            int i = ((MathHelper2.Floor_double((double)((par5EntityLiving.RotationYaw * 4F) / 360F) + 0.5D) & 3) + 2) % 4;

            par1World.SetBlockMetadataWithNotify(par2, par3, par4, i);
            bool flag = IgnoreTick(par1World, par2, par3, par4, i);

            if (flag)
            {
                par1World.ScheduleBlockUpdate(par2, par3, par4, BlockID, 1);
            }
        }
Beispiel #26
0
        public Packet71Weather(Entity par1Entity)
        {
            EntityID = par1Entity.EntityId;
            PosX     = MathHelper2.Floor_double(par1Entity.PosX * 32D);
            PosY     = MathHelper2.Floor_double(par1Entity.PosY * 32D);
            PosZ     = MathHelper2.Floor_double(par1Entity.PosZ * 32D);

            if (par1Entity is EntityLightningBolt)
            {
                IsLightningBolt = 1;
            }
        }
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (DelayBeforeCanPickup > 0)
            {
                DelayBeforeCanPickup--;
            }

            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;
            MotionY -= 0.039999999105930328F;

            if (WorldObj.GetBlockMaterial(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)) == Material.Lava)
            {
                MotionY = 0.20000000298023224F;
                MotionX = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                MotionZ = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                WorldObj.PlaySoundAtEntity(this, "random.fizz", 0.4F, 2.0F + Rand.NextFloat() * 0.4F);
            }

            PushOutOfBlocks(PosX, (BoundingBox.MinY + BoundingBox.MaxY) / 2F, PosZ);
            MoveEntity(MotionX, MotionY, MotionZ);
            float f = 0.98F;

            if (OnGround)
            {
                f = 0.5880001F;
                int i = WorldObj.GetBlockId(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(BoundingBox.MinY) - 1, MathHelper2.Floor_double(PosZ));

                if (i > 0)
                {
                    f = Block.BlocksList[i].Slipperiness * 0.98F;
                }
            }

            MotionX *= f;
            MotionY *= 0.98000001907348633F;
            MotionZ *= f;

            if (OnGround)
            {
                MotionY *= -0.5F;
            }

            Age++;

            if (Age >= 6000)
            {
                SetDead();
            }
        }
 public Packet24MobSpawn(EntityLiving par1EntityLiving)
 {
     EntityId      = par1EntityLiving.EntityId;
     Type          = (sbyte)EntityList.GetEntityID(par1EntityLiving);
     XPosition     = MathHelper2.Floor_double(par1EntityLiving.PosX * 32D);
     YPosition     = MathHelper2.Floor_double(par1EntityLiving.PosY * 32D);
     ZPosition     = MathHelper2.Floor_double(par1EntityLiving.PosZ * 32D);
     Yaw           = (sbyte)(int)((par1EntityLiving.RotationYaw * 256F) / 360F);
     Pitch         = (sbyte)(int)((par1EntityLiving.RotationPitch * 256F) / 360F);
     Field_48169_h = (sbyte)(int)((par1EntityLiving.RotationYawHead * 256F) / 360F);
     MetaData      = par1EntityLiving.GetDataWatcher();
 }
Beispiel #29
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (LightningState == 2)
            {
                WorldObj.PlaySoundEffect(PosX, PosY, PosZ, "ambient.weather.thunder", 10000F, 0.8F + Rand.NextFloat() * 0.2F);
                WorldObj.PlaySoundEffect(PosX, PosY, PosZ, "random.explode", 2.0F, 0.5F + Rand.NextFloat() * 0.2F);
            }

            LightningState--;

            if (LightningState < 0)
            {
                if (BoltLivingTime == 0)
                {
                    SetDead();
                }
                else if (LightningState < -Rand.Next(10))
                {
                    BoltLivingTime--;
                    LightningState = 1;
                    BoltVertex     = Rand.Next();

                    if (WorldObj.DoChunksNearChunkExist(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ), 10))
                    {
                        int i = MathHelper2.Floor_double(PosX);
                        int j = MathHelper2.Floor_double(PosY);
                        int k = MathHelper2.Floor_double(PosZ);

                        if (WorldObj.GetBlockId(i, j, k) == 0 && Block.Fire.CanPlaceBlockAt(WorldObj, i, j, k))
                        {
                            WorldObj.SetBlockWithNotify(i, j, k, Block.Fire.BlockID);
                        }
                    }
                }
            }

            if (LightningState >= 0)
            {
                float         d    = 3;
                List <Entity> list = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.GetBoundingBoxFromPool(PosX - d, PosY - d, PosZ - d, PosX + d, PosY + 6 + d, PosZ + d));

                for (int l = 0; l < list.Count; l++)
                {
                    Entity entity = list[l];
                    entity.OnStruckByLightning(this);
                }

                WorldObj.LightningFlash = 2;
            }
        }
Beispiel #30
0
        public Packet20NamedEntitySpawn(EntityPlayer par1EntityPlayer)
        {
            EntityId  = par1EntityPlayer.EntityId;
            Name      = par1EntityPlayer.Username;
            XPosition = MathHelper2.Floor_double(par1EntityPlayer.PosX * 32D);
            YPosition = MathHelper2.Floor_double(par1EntityPlayer.PosY * 32D);
            ZPosition = MathHelper2.Floor_double(par1EntityPlayer.PosZ * 32D);
            Rotation  = (sbyte)(int)((par1EntityPlayer.RotationYaw * 256F) / 360F);
            Pitch     = (sbyte)(int)((par1EntityPlayer.RotationPitch * 256F) / 360F);
            ItemStack itemstack = par1EntityPlayer.Inventory.GetCurrentItem();

            CurrentItem = itemstack != null ? itemstack.ItemID : 0;
        }