private WorldDB() { var assembly = Assembly.GetExecutingAssembly(); var resourceName = "AlbionMarshaller.Resources.world.xml"; // Old_ using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { XDocument worldDoc = XDocument.Parse(reader.ReadToEnd()); int i = 0; foreach (XElement loc in worldDoc.Root.Element("clusters").Descendants("cluster")) { string id = loc.Attribute("id").Value; string displayName = loc.Attribute("displayname").Value; string worldType = loc.Attribute("type").Value; string fileName = loc.Attribute("file").Value; string timeregion = loc.Attribute("timeregion").Value; int tier = int.Parse(Regex.Match(fileName, "_T(\\d)_").Groups[1].ToString()); WorldObj worldObj = new WorldObj() { ID = id, DisplayName = displayName, WorldType = worldType, FileName = fileName, Tier = tier, TimeRegion = timeregion }; _nameToDisplay.Add(id, worldObj); i++; } } }
private void UpdatePushedObjects(float par1, float par2) { if (!Extending) { par1--; } else { par1 = 1.0F - par1; } AxisAlignedBB axisalignedbb = Block.PistonMoving.GetAxisAlignedBB(WorldObj, XCoord, YCoord, ZCoord, StoredBlockID, par1, StoredOrientation); if (axisalignedbb != null) { List <Entity> list = WorldObj.GetEntitiesWithinAABBExcludingEntity(null, axisalignedbb); if (list.Count > 0) { PushedObjects.AddRange(list); Entity entity; for (IEnumerator <Entity> iterator = PushedObjects.GetEnumerator(); iterator.MoveNext(); entity.MoveEntity(par2 * (float)Facing.OffsetsXForSide[StoredOrientation], par2 * (float)Facing.OffsetsYForSide[StoredOrientation], par2 * (float)Facing.OffsetsZForSide[StoredOrientation])) { entity = iterator.Current; } PushedObjects.Clear(); } } }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { PrevPosX = PosX; PrevPosY = PosY; PrevPosZ = PosZ; if (ParticleAge++ >= ParticleMaxAge) { SetDead(); } SetParticleTextureIndex(7 - (ParticleAge * 8) / ParticleMaxAge); MoveEntity(MotionX, MotionY, MotionZ); MotionX *= 0.95999997854232788F; MotionY *= 0.95999997854232788F; MotionZ *= 0.95999997854232788F; EntityPlayer entityplayer = WorldObj.GetClosestPlayerToEntity(this, 2); if (entityplayer != null && PosY > entityplayer.BoundingBox.MinY) { PosY += (entityplayer.BoundingBox.MinY - PosY) * 0.20000000000000001F; MotionY += (entityplayer.MotionY - MotionY) * 0.20000000000000001F; SetPosition(PosX, PosY, PosZ); } if (OnGround) { MotionX *= 0.69999998807907104F; MotionZ *= 0.69999998807907104F; } }
/// <summary> /// Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count /// ticks and creates a new spawn inside its implementation. /// </summary> public override void UpdateEntity() { LastProgress = Progress; if (LastProgress >= 1.0F) { UpdatePushedObjects(1.0F, 0.25F); WorldObj.RemoveBlockTileEntity(XCoord, YCoord, ZCoord); Invalidate(); if (WorldObj.GetBlockId(XCoord, YCoord, ZCoord) == Block.PistonMoving.BlockID) { WorldObj.SetBlockAndMetadataWithNotify(XCoord, YCoord, ZCoord, StoredBlockID, StoredMetadata); } return; } Progress += 0.5F; if (Progress >= 1.0F) { Progress = 1.0F; } if (Extending) { UpdatePushedObjects(Progress, (Progress - LastProgress) + 0.0625F); } }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { PrevPosX = PosX; PrevPosY = PosY; PrevPosZ = PosZ; MotionY -= 0.039999999105930328F; MoveEntity(MotionX, MotionY, MotionZ); MotionX *= 0.98000001907348633F; MotionY *= 0.98000001907348633F; MotionZ *= 0.98000001907348633F; if (OnGround) { MotionX *= 0.69999998807907104F; MotionZ *= 0.69999998807907104F; MotionY *= -0.5F; } if (Fuse-- <= 0) { if (!WorldObj.IsRemote) { SetDead(); Explode(); } else { SetDead(); } } else { WorldObj.SpawnParticle("smoke", PosX, PosY + 0.5D, PosZ, 0.0F, 0.0F, 0.0F); } }
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); }
/// <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); }
/// <summary> /// Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. /// </summary> public override bool Interact(EntityPlayer par1EntityPlayer) { ItemStack itemstack = par1EntityPlayer.Inventory.GetCurrentItem(); if (itemstack != null && IsWheat(itemstack) && GetGrowingAge() == 0) { if (!par1EntityPlayer.Capabilities.IsCreativeMode) { itemstack.StackSize--; if (itemstack.StackSize <= 0) { par1EntityPlayer.Inventory.SetInventorySlotContents(par1EntityPlayer.Inventory.CurrentItem, null); } } InLove = 600; EntityToAttack = null; for (int i = 0; i < 7; i++) { double d = Rand.NextGaussian() * 0.02D; double d1 = Rand.NextGaussian() * 0.02D; double d2 = Rand.NextGaussian() * 0.02D; WorldObj.SpawnParticle("heart", (PosX + (double)(Rand.NextFloat() * Width * 2.0F)) - (double)Width, PosY + 0.5D + (double)(Rand.NextFloat() * Height), (PosZ + (double)(Rand.NextFloat() * Width * 2.0F)) - (double)Width, d, d1, d2); } return(true); } else { return(base.Interact(par1EntityPlayer)); } }
/// <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 (GetGrowingAge() != 0) { InLove = 0; } if (InLove > 0) { InLove--; string s = "heart"; if (InLove % 10 == 0) { double d = Rand.NextGaussian() * 0.02D; double d1 = Rand.NextGaussian() * 0.02D; double d2 = Rand.NextGaussian() * 0.02D; WorldObj.SpawnParticle(s, (PosX + (double)(Rand.NextFloat() * Width * 2.0F)) - (double)Width, PosY + 0.5D + (double)(Rand.NextFloat() * Height), (PosZ + (double)(Rand.NextFloat() * Width * 2.0F)) - (double)Width, d, d1, d2); } } else { Breeding = 0; } }
/// <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 (IsWet()) { AttackEntityFrom(DamageSource.Drown, 1); } int i = MathHelper2.Floor_double(PosX); int k = MathHelper2.Floor_double(PosZ); if (WorldObj.GetBiomeGenForCoords(i, k).GetFloatTemperature() > 1.0F) { AttackEntityFrom(DamageSource.OnFire, 1); } for (int j = 0; j < 4; j++) { int l = MathHelper2.Floor_double(PosX + (double)((float)((j % 2) * 2 - 1) * 0.25F)); int i1 = MathHelper2.Floor_double(PosY); int j1 = MathHelper2.Floor_double(PosZ + (double)((float)(((j / 2) % 2) * 2 - 1) * 0.25F)); if (WorldObj.GetBlockId(l, i1, j1) == 0 && WorldObj.GetBiomeGenForCoords(l, j1).GetFloatTemperature() < 0.8F && Block.Snow.CanPlaceBlockAt(WorldObj, l, i1, j1)) { WorldObj.SetBlockWithNotify(l, i1, j1, Block.Snow.BlockID); } } }
/// <summary> /// Creates a baby animal according to the animal type of the target at the actual position and spawns 'love' /// particles. /// </summary> private void Procreate(EntityAnimal par1EntityAnimal) { EntityAnimal entityanimal = SpawnBabyAnimal(par1EntityAnimal); if (entityanimal != null) { SetGrowingAge(6000); par1EntityAnimal.SetGrowingAge(6000); InLove = 0; Breeding = 0; EntityToAttack = null; par1EntityAnimal.EntityToAttack = null; par1EntityAnimal.Breeding = 0; par1EntityAnimal.InLove = 0; entityanimal.SetGrowingAge(-24000); entityanimal.SetLocationAndAngles(PosX, PosY, PosZ, RotationYaw, RotationPitch); for (int i = 0; i < 7; i++) { double d = Rand.NextGaussian() * 0.02D; double d1 = Rand.NextGaussian() * 0.02D; double d2 = Rand.NextGaussian() * 0.02D; WorldObj.SpawnParticle("heart", (PosX + (double)(Rand.NextFloat() * Width * 2.0F)) - (double)Width, PosY + 0.5D + (double)(Rand.NextFloat() * Height), (PosZ + (double)(Rand.NextFloat() * Width * 2.0F)) - (double)Width, d, d1, d2); } WorldObj.SpawnEntityInWorld(entityanimal); } }
/// <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> /// Called when the throwable hits a block or entity. /// </summary> protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.EntityHit != null) { if (!par1MovingObjectPosition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Thrower), 0)) { ; } } for (int i = 0; i < 32; i++) { WorldObj.SpawnParticle("portal", PosX, PosY + Rand.NextFloat() * 2, PosZ, Rand.NextGaussian(), 0.0F, Rand.NextGaussian()); } if (!WorldObj.IsRemote) { if (Thrower != null) { Thrower.SetPositionAndUpdate(PosX, PosY, PosZ); Thrower.FallDistance = 0.0F; Thrower.AttackEntityFrom(DamageSource.Fall, 5); } SetDead(); } }
/// <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(); }
///<summary> /// Called to update the entity's position/logic. ///</summary> public new void OnUpdate() { PrevPosX = PosX; PrevPosY = PosY; PrevPosZ = PosZ; if (ParticleAge++ >= ParticleMaxAge) { SetDead(); } float f = (float)ParticleAge / (float)ParticleMaxAge; if ((float)Rand.NextDouble() > f) { WorldObj.SpawnParticle("smoke", PosX, PosY, PosZ, MotionX, MotionY, MotionZ); } MotionY -= 0.029999999999999999F; MoveEntity(MotionX, MotionY, MotionZ); MotionX *= 0.99900001287460327F; MotionY *= 0.99900001287460327F; MotionZ *= 0.99900001287460327F; if (OnGround) { MotionX *= 0.69999998807907104F; MotionZ *= 0.69999998807907104F; } }
/// <summary> /// Called when the throwable hits a block or entity. /// </summary> protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.EntityHit != null) { sbyte byte0 = 0; if (par1MovingObjectPosition.EntityHit is EntityBlaze) { byte0 = 3; } if (!par1MovingObjectPosition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Thrower), byte0)) { ; } } for (int i = 0; i < 8; i++) { WorldObj.SpawnParticle("snowballpoof", PosX, PosY, PosZ, 0.0F, 0.0F, 0.0F); } if (!WorldObj.IsRemote) { SetDead(); } }
/// <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()); }
/// <summary> /// Adds to the current velocity of the entity. Args: x, y, z /// </summary> public override void AddVelocity(float par1, float par3, float par5) { if (!WorldObj.IsRemote && !IsDead && par1 * par1 + par3 * par3 + par5 * par5 > 0.0F) { SetDead(); WorldObj.SpawnEntityInWorld(new EntityItem(WorldObj, PosX, PosY, PosZ, new ItemStack(Item.Painting))); } }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { base.OnUpdate(); Field_25054_c = Field_25048_b; if (LooksWithInterest) { Field_25048_b = Field_25048_b + (1.0F - Field_25048_b) * 0.4F; } else { Field_25048_b = Field_25048_b + (0.0F - Field_25048_b) * 0.4F; } if (LooksWithInterest) { NumTicksToChaseTarget = 10; } if (IsWet()) { IsShaking = true; Field_25052_g = false; TimeWolfIsShaking = 0.0F; PrevTimeWolfIsShaking = 0.0F; } else if ((IsShaking || Field_25052_g) && Field_25052_g) { if (TimeWolfIsShaking == 0.0F) { WorldObj.PlaySoundAtEntity(this, "mob.wolf.shake", GetSoundVolume(), (Rand.NextFloat() - Rand.NextFloat()) * 0.2F + 1.0F); } PrevTimeWolfIsShaking = TimeWolfIsShaking; TimeWolfIsShaking += 0.05F; if (PrevTimeWolfIsShaking >= 2.0F) { IsShaking = false; Field_25052_g = false; PrevTimeWolfIsShaking = 0.0F; TimeWolfIsShaking = 0.0F; } if (TimeWolfIsShaking > 0.4F) { float f = (float)BoundingBox.MinY; int i = (int)(MathHelper2.Sin((TimeWolfIsShaking - 0.4F) * (float)Math.PI) * 7F); for (int j = 0; j < i; j++) { float f1 = (Rand.NextFloat() * 2.0F - 1.0F) * Width * 0.5F; float f2 = (Rand.NextFloat() * 2.0F - 1.0F) * Width * 0.5F; WorldObj.SpawnParticle("splash", PosX + (double)f1, f + 0.8F, PosZ + (double)f2, MotionX, MotionY, MotionZ); } } } }
protected override bool CanSpawnStructureAtCoords(int par1, int par2) { if (!RanBiomeCheck) { Random random = new Random(); random.SetSeed((int)WorldObj.GetSeed()); double d = random.NextDouble() * Math.PI * 2D; for (int k = 0; k < StructureCoords.Length; k++) { double d1 = (1.25D + random.NextDouble()) * 32D; int l = (int)Math.Round(Math.Cos(d) * d1); int i1 = (int)Math.Round(Math.Sin(d) * d1); List <BiomeGenBase> arraylist = new List <BiomeGenBase>(); BiomeGenBase[] abiomegenbase = AllowedBiomeGenBases; int j1 = abiomegenbase.Length; for (int k1 = 0; k1 < j1; k1++) { BiomeGenBase biomegenbase = abiomegenbase[k1]; arraylist.Add(biomegenbase); } ChunkPosition chunkposition = WorldObj.GetWorldChunkManager().FindBiomePosition((l << 4) + 8, (i1 << 4) + 8, 112, arraylist, random); if (chunkposition != null) { l = chunkposition.x >> 4; i1 = chunkposition.z >> 4; } else { Console.WriteLine((new StringBuilder()).Append("Placed stronghold in INVALID biome at (").Append(l).Append(", ").Append(i1).Append(")").ToString()); } StructureCoords[k] = new ChunkCoordIntPair(l, i1); d += (Math.PI * 2D) / (double)StructureCoords.Length; } RanBiomeCheck = true; } ChunkCoordIntPair[] achunkcoordintpair = StructureCoords; int i = achunkcoordintpair.Length; for (int j = 0; j < i; j++) { ChunkCoordIntPair chunkcoordintpair = achunkcoordintpair[j]; if (par1 == chunkcoordintpair.ChunkXPos && par2 == chunkcoordintpair.ChunkZPos) { Console.WriteLine((new StringBuilder()).Append(par1).Append(", ").Append(par2).ToString()); return(true); } } return(false); }
/// <summary> /// Do not make give this method the name canInteractWith because it clashes with Container /// </summary> public virtual bool IsUseableByPlayer(EntityPlayer par1EntityPlayer) { if (WorldObj.GetBlockTileEntity(XCoord, YCoord, ZCoord) != this) { return(false); } return(par1EntityPlayer.GetDistanceSq(XCoord + 0.5F, YCoord + 0.5F, ZCoord + 0.5F) <= 64); }
/// <summary> /// Called when the throwable hits a block or entity. /// </summary> protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition) { if (!WorldObj.IsRemote) { List <PotionEffect> list = Item.Potion.GetEffects(PotionDamage); if (list != null && list.Count > 0) { AxisAlignedBB axisalignedbb = BoundingBox.Expand(4, 2, 4); List <Entity> list1 = WorldObj.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityLiving), axisalignedbb); if (list1 != null && list1.Count > 0) { for (IEnumerator <Entity> iterator = list1.GetEnumerator(); iterator.MoveNext();) { Entity entity = iterator.Current; double d = GetDistanceSqToEntity(entity); if (d < 16D) { double d1 = 1.0D - Math.Sqrt(d) / 4D; if (entity == par1MovingObjectPosition.EntityHit) { d1 = 1.0D; } IEnumerator <PotionEffect> iterator1 = list.GetEnumerator(); while (iterator1.MoveNext()) { PotionEffect potioneffect = iterator1.Current; int i = potioneffect.GetPotionID(); if (Potion.PotionTypes[i].IsInstant()) { Potion.PotionTypes[i].AffectEntity(Thrower, (EntityLiving)entity, potioneffect.GetAmplifier(), d1); } else { int j = (int)(d1 * (double)potioneffect.GetDuration() + 0.5D); if (j > 20) { ((EntityLiving)entity).AddPotionEffect(new PotionEffect(i, j, potioneffect.GetAmplifier())); } } } } } } } WorldObj.PlayAuxSFX(2002, (int)Math.Round(PosX), (int)Math.Round(PosY), (int)Math.Round(PosZ), PotionDamage); SetDead(); } }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { MoveSpeed = EntityToAttack == null ? 0.5F : 0.95F; if (RandomSoundDelay > 0 && --RandomSoundDelay == 0) { WorldObj.PlaySoundAtEntity(this, "mob.zombiepig.zpigangry", GetSoundVolume() * 2.0F, ((Rand.NextFloat() - Rand.NextFloat()) * 0.2F + 1.0F) * 1.8F); } base.OnUpdate(); }
/// <summary> /// Takes a coordinate in and returns a weight to determine how likely this creature will try to path to the block. /// Args: x, y, z /// </summary> public override float GetBlockPathWeight(int par1, int par2, int par3) { if (WorldObj.GetBlockId(par1, par2 - 1, par3) == Block.Grass.BlockID) { return(10F); } else { return(WorldObj.GetLightBrightness(par1, par2, par3) - 0.5F); } }
/// <summary> /// Called when the entity is attacked. /// </summary> public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2) { if (!IsDead && !WorldObj.IsRemote) { SetDead(); SetBeenAttacked(); WorldObj.SpawnEntityInWorld(new EntityItem(WorldObj, PosX, PosY, PosZ, new ItemStack(Item.Painting))); } return(true); }
/// <summary> /// Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking /// (Animals, Spiders at day, peaceful PigZombies). /// </summary> protected override Entity FindPlayerToAttack() { if (FleeingTick > 0) { return(null); } float f = 8F; if (InLove > 0) { List <Entity> list = WorldObj.GetEntitiesWithinAABB(this.GetType(), BoundingBox.Expand(f, f, f)); for (int i = 0; i < list.Count; i++) { EntityAnimal entityanimal = (EntityAnimal)list[i]; if (entityanimal != this && entityanimal.InLove > 0) { return(entityanimal); } } } else if (GetGrowingAge() == 0) { List <Entity> list1 = WorldObj.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityPlayer), BoundingBox.Expand(f, f, f)); for (int j = 0; j < list1.Count; j++) { EntityPlayer entityplayer = (EntityPlayer)list1[j]; if (entityplayer.GetCurrentEquippedItem() != null && IsWheat(entityplayer.GetCurrentEquippedItem())) { return(entityplayer); } } } else if (GetGrowingAge() > 0) { List <Entity> list2 = WorldObj.GetEntitiesWithinAABB(this.GetType(), BoundingBox.Expand(f, f, f)); for (int k = 0; k < list2.Count; k++) { EntityAnimal entityanimal1 = (EntityAnimal)list2[k]; if (entityanimal1 != this && entityanimal1.GetGrowingAge() < 0) { return(entityanimal1); } } } return(null); }
/// <summary> /// Takes a coordinate in and returns a weight to determine how likely this creature will try to path to the block. /// Args: x, y, z /// </summary> public override float GetBlockPathWeight(int par1, int par2, int par3) { if (WorldObj.GetBlockId(par1, par2 - 1, par3) == Block.Stone.BlockID) { return(10F); } else { return(base.GetBlockPathWeight(par1, par2, par3)); } }
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); } }
/// <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(); } }
/// <summary> /// performs the check for adjacent chests to determine if this chest is double or not. /// </summary> public virtual void CheckForAdjacentChests() { if (AdjacentChestChecked) { return; } AdjacentChestChecked = true; AdjacentChestZNeg = null; AdjacentChestXPos = null; AdjacentChestXNeg = null; AdjacentChestZPos = null; if (WorldObj.GetBlockId(XCoord - 1, YCoord, ZCoord) == Block.Chest.BlockID) { AdjacentChestXNeg = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord - 1, YCoord, ZCoord); } if (WorldObj.GetBlockId(XCoord + 1, YCoord, ZCoord) == Block.Chest.BlockID) { AdjacentChestXPos = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord + 1, YCoord, ZCoord); } if (WorldObj.GetBlockId(XCoord, YCoord, ZCoord - 1) == Block.Chest.BlockID) { AdjacentChestZNeg = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord, YCoord, ZCoord - 1); } if (WorldObj.GetBlockId(XCoord, YCoord, ZCoord + 1) == Block.Chest.BlockID) { AdjacentChestZPos = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord, YCoord, ZCoord + 1); } if (AdjacentChestZNeg != null) { AdjacentChestZNeg.UpdateContainingBlockInfo(); } if (AdjacentChestZPos != null) { AdjacentChestZPos.UpdateContainingBlockInfo(); } if (AdjacentChestXPos != null) { AdjacentChestXPos.UpdateContainingBlockInfo(); } if (AdjacentChestXNeg != null) { AdjacentChestXNeg.UpdateContainingBlockInfo(); } }