001    package net.minecraft.entity;
002    
003    import cpw.mods.fml.relauncher.Side;
004    import cpw.mods.fml.relauncher.SideOnly;
005    
006    import java.util.ArrayList;
007    import java.util.List;
008    import java.util.Random;
009    import java.util.UUID;
010    
011    import net.minecraft.block.Block;
012    import net.minecraft.block.BlockFluid;
013    import net.minecraft.block.StepSound;
014    import net.minecraft.block.material.Material;
015    import net.minecraft.crash.CrashReport;
016    import net.minecraft.crash.CrashReportCategory;
017    import net.minecraft.enchantment.EnchantmentProtection;
018    import net.minecraft.entity.effect.EntityLightningBolt;
019    import net.minecraft.entity.item.EntityBoat;
020    import net.minecraft.entity.item.EntityItem;
021    import net.minecraft.entity.item.EntityItemFrame;
022    import net.minecraft.entity.item.EntityMinecart;
023    import net.minecraft.entity.item.EntityPainting;
024    import net.minecraft.entity.player.EntityPlayer;
025    import net.minecraft.item.Item;
026    import net.minecraft.item.ItemStack;
027    import net.minecraft.nbt.NBTTagCompound;
028    import net.minecraft.nbt.NBTTagDouble;
029    import net.minecraft.nbt.NBTTagFloat;
030    import net.minecraft.nbt.NBTTagList;
031    import net.minecraft.server.MinecraftServer;
032    import net.minecraft.util.AxisAlignedBB;
033    import net.minecraft.util.DamageSource;
034    import net.minecraft.util.Direction;
035    import net.minecraft.util.MathHelper;
036    import net.minecraft.util.MovingObjectPosition;
037    import net.minecraft.util.ReportedException;
038    import net.minecraft.util.StatCollector;
039    import net.minecraft.util.Vec3;
040    import net.minecraft.world.Explosion;
041    import net.minecraft.world.World;
042    import net.minecraft.world.WorldServer;
043    
044    public abstract class Entity
045    {
046        private static int nextEntityID = 0;
047        public int entityId;
048        public double renderDistanceWeight;
049    
050        /**
051         * Blocks entities from spawning when they do their AABB check to make sure the spot is clear of entities that can
052         * prevent spawning.
053         */
054        public boolean preventEntitySpawning;
055    
056        /** The entity that is riding this entity */
057        public Entity riddenByEntity;
058    
059        /** The entity we are currently riding */
060        public Entity ridingEntity;
061    
062        /** Reference to the World object. */
063        public World worldObj;
064        public double prevPosX;
065        public double prevPosY;
066        public double prevPosZ;
067    
068        /** Entity position X */
069        public double posX;
070    
071        /** Entity position Y */
072        public double posY;
073    
074        /** Entity position Z */
075        public double posZ;
076    
077        /** Entity motion X */
078        public double motionX;
079    
080        /** Entity motion Y */
081        public double motionY;
082    
083        /** Entity motion Z */
084        public double motionZ;
085    
086        /** Entity rotation Yaw */
087        public float rotationYaw;
088    
089        /** Entity rotation Pitch */
090        public float rotationPitch;
091        public float prevRotationYaw;
092        public float prevRotationPitch;
093    
094        /** Axis aligned bounding box. */
095        public final AxisAlignedBB boundingBox;
096        public boolean onGround;
097    
098        /**
099         * True if after a move this entity has collided with something on X- or Z-axis
100         */
101        public boolean isCollidedHorizontally;
102    
103        /**
104         * True if after a move this entity has collided with something on Y-axis
105         */
106        public boolean isCollidedVertically;
107    
108        /**
109         * True if after a move this entity has collided with something either vertically or horizontally
110         */
111        public boolean isCollided;
112        public boolean velocityChanged;
113        protected boolean isInWeb;
114        public boolean field_70135_K;
115    
116        /**
117         * Gets set by setDead, so this must be the flag whether an Entity is dead (inactive may be better term)
118         */
119        public boolean isDead;
120        public float yOffset;
121    
122        /** How wide this entity is considered to be */
123        public float width;
124    
125        /** How high this entity is considered to be */
126        public float height;
127    
128        /** The previous ticks distance walked multiplied by 0.6 */
129        public float prevDistanceWalkedModified;
130    
131        /** The distance walked multiplied by 0.6 */
132        public float distanceWalkedModified;
133        public float field_82151_R;
134        public float fallDistance;
135    
136        /**
137         * The distance that has to be exceeded in order to triger a new step sound and an onEntityWalking event on a block
138         */
139        private int nextStepDistance;
140    
141        /**
142         * The entity's X coordinate at the previous tick, used to calculate position during rendering routines
143         */
144        public double lastTickPosX;
145    
146        /**
147         * The entity's Y coordinate at the previous tick, used to calculate position during rendering routines
148         */
149        public double lastTickPosY;
150    
151        /**
152         * The entity's Z coordinate at the previous tick, used to calculate position during rendering routines
153         */
154        public double lastTickPosZ;
155        public float ySize;
156    
157        /**
158         * How high this entity can step up when running into a block to try to get over it (currently make note the entity
159         * will always step up this amount and not just the amount needed)
160         */
161        public float stepHeight;
162    
163        /**
164         * Whether this entity won't clip with collision or not (make note it won't disable gravity)
165         */
166        public boolean noClip;
167    
168        /**
169         * Reduces the velocity applied by entity collisions by the specified percent.
170         */
171        public float entityCollisionReduction;
172        protected Random rand;
173    
174        /** How many ticks has this entity had ran since being alive */
175        public int ticksExisted;
176    
177        /**
178         * The amount of ticks you have to stand inside of fire before be set on fire
179         */
180        public int fireResistance;
181        private int fire;
182    
183        /**
184         * Whether this entity is currently inside of water (if it handles water movement that is)
185         */
186        protected boolean inWater;
187    
188        /**
189         * Remaining time an entity will be "immune" to further damage after being hurt.
190         */
191        public int hurtResistantTime;
192        private boolean firstUpdate;
193        @SideOnly(Side.CLIENT)
194    
195        /** downloadable location of player's skin */
196        public String skinUrl;
197        @SideOnly(Side.CLIENT)
198    
199        /** downloadable location of player's cloak */
200        public String cloakUrl;
201        protected boolean isImmuneToFire;
202        protected DataWatcher dataWatcher;
203        private double entityRiderPitchDelta;
204        private double entityRiderYawDelta;
205    
206        /** Has this entity been added to the chunk its within */
207        public boolean addedToChunk;
208        public int chunkCoordX;
209        public int chunkCoordY;
210        public int chunkCoordZ;
211        @SideOnly(Side.CLIENT)
212        public int serverPosX;
213        @SideOnly(Side.CLIENT)
214        public int serverPosY;
215        @SideOnly(Side.CLIENT)
216        public int serverPosZ;
217    
218        /**
219         * Render entity even if it is outside the camera frustum. Only true in EntityFish for now. Used in RenderGlobal:
220         * render if ignoreFrustumCheck or in frustum.
221         */
222        public boolean ignoreFrustumCheck;
223        public boolean isAirBorne;
224        public int timeUntilPortal;
225    
226        /** Whether the entity is inside a Portal */
227        protected boolean inPortal;
228        protected int field_82153_h;
229    
230        /** Which dimension the player is in (-1 = the Nether, 0 = normal world) */
231        public int dimension;
232        protected int field_82152_aq;
233        private boolean field_83001_bt;
234        public EnumEntitySize myEntitySize;
235        /** Forge: Used to store custom data for each entity. */
236        private NBTTagCompound customEntityData;
237        public boolean captureDrops = false;
238        public ArrayList<EntityItem> capturedDrops = new ArrayList<EntityItem>();
239        private UUID persistentID;
240    
241        public Entity(World par1World)
242        {
243            this.entityId = nextEntityID++;
244            this.renderDistanceWeight = 1.0D;
245            this.preventEntitySpawning = false;
246            this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
247            this.onGround = false;
248            this.isCollided = false;
249            this.velocityChanged = false;
250            this.field_70135_K = true;
251            this.isDead = false;
252            this.yOffset = 0.0F;
253            this.width = 0.6F;
254            this.height = 1.8F;
255            this.prevDistanceWalkedModified = 0.0F;
256            this.distanceWalkedModified = 0.0F;
257            this.field_82151_R = 0.0F;
258            this.fallDistance = 0.0F;
259            this.nextStepDistance = 1;
260            this.ySize = 0.0F;
261            this.stepHeight = 0.0F;
262            this.noClip = false;
263            this.entityCollisionReduction = 0.0F;
264            this.rand = new Random();
265            this.ticksExisted = 0;
266            this.fireResistance = 1;
267            this.fire = 0;
268            this.inWater = false;
269            this.hurtResistantTime = 0;
270            this.firstUpdate = true;
271            this.isImmuneToFire = false;
272            this.dataWatcher = new DataWatcher();
273            this.addedToChunk = false;
274            this.field_82152_aq = 0;
275            this.field_83001_bt = false;
276            this.myEntitySize = EnumEntitySize.SIZE_2;
277            this.worldObj = par1World;
278            this.setPosition(0.0D, 0.0D, 0.0D);
279    
280            if (par1World != null)
281            {
282                this.dimension = par1World.provider.dimensionId;
283            }
284    
285            this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
286            this.dataWatcher.addObject(1, Short.valueOf((short)300));
287            this.entityInit();
288        }
289    
290        protected abstract void entityInit();
291    
292        public DataWatcher getDataWatcher()
293        {
294            return this.dataWatcher;
295        }
296    
297        public boolean equals(Object par1Obj)
298        {
299            return par1Obj instanceof Entity ? ((Entity)par1Obj).entityId == this.entityId : false;
300        }
301    
302        public int hashCode()
303        {
304            return this.entityId;
305        }
306    
307        @SideOnly(Side.CLIENT)
308    
309        /**
310         * Keeps moving the entity up so it isn't colliding with blocks and other requirements for this entity to be spawned
311         * (only actually used on players though its also on Entity)
312         */
313        protected void preparePlayerToSpawn()
314        {
315            if (this.worldObj != null)
316            {
317                while (this.posY > 0.0D)
318                {
319                    this.setPosition(this.posX, this.posY, this.posZ);
320    
321                    if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty())
322                    {
323                        break;
324                    }
325    
326                    ++this.posY;
327                }
328    
329                this.motionX = this.motionY = this.motionZ = 0.0D;
330                this.rotationPitch = 0.0F;
331            }
332        }
333    
334        /**
335         * Will get destroyed next tick.
336         */
337        public void setDead()
338        {
339            this.isDead = true;
340        }
341    
342        /**
343         * Sets the width and height of the entity. Args: width, height
344         */
345        protected void setSize(float par1, float par2)
346        {
347            this.width = par1;
348            this.height = par2;
349            float var3 = par1 % 2.0F;
350    
351            if ((double)var3 < 0.375D)
352            {
353                this.myEntitySize = EnumEntitySize.SIZE_1;
354            }
355            else if ((double)var3 < 0.75D)
356            {
357                this.myEntitySize = EnumEntitySize.SIZE_2;
358            }
359            else if ((double)var3 < 1.0D)
360            {
361                this.myEntitySize = EnumEntitySize.SIZE_3;
362            }
363            else if ((double)var3 < 1.375D)
364            {
365                this.myEntitySize = EnumEntitySize.SIZE_4;
366            }
367            else if ((double)var3 < 1.75D)
368            {
369                this.myEntitySize = EnumEntitySize.SIZE_5;
370            }
371            else
372            {
373                this.myEntitySize = EnumEntitySize.SIZE_6;
374            }
375        }
376    
377        /**
378         * Sets the rotation of the entity
379         */
380        protected void setRotation(float par1, float par2)
381        {
382            this.rotationYaw = par1 % 360.0F;
383            this.rotationPitch = par2 % 360.0F;
384        }
385    
386        /**
387         * Sets the x,y,z of the entity from the given parameters. Also seems to set up a bounding box.
388         */
389        public void setPosition(double par1, double par3, double par5)
390        {
391            this.posX = par1;
392            this.posY = par3;
393            this.posZ = par5;
394            float var7 = this.width / 2.0F;
395            float var8 = this.height;
396            this.boundingBox.setBounds(par1 - (double)var7, par3 - (double)this.yOffset + (double)this.ySize, par5 - (double)var7, par1 + (double)var7, par3 - (double)this.yOffset + (double)this.ySize + (double)var8, par5 + (double)var7);
397        }
398    
399        @SideOnly(Side.CLIENT)
400    
401        /**
402         * Adds par1*0.15 to the entity's yaw, and *subtracts* par2*0.15 from the pitch. Clamps pitch from -90 to 90. Both
403         * arguments in degrees.
404         */
405        public void setAngles(float par1, float par2)
406        {
407            float var3 = this.rotationPitch;
408            float var4 = this.rotationYaw;
409            this.rotationYaw = (float)((double)this.rotationYaw + (double)par1 * 0.15D);
410            this.rotationPitch = (float)((double)this.rotationPitch - (double)par2 * 0.15D);
411    
412            if (this.rotationPitch < -90.0F)
413            {
414                this.rotationPitch = -90.0F;
415            }
416    
417            if (this.rotationPitch > 90.0F)
418            {
419                this.rotationPitch = 90.0F;
420            }
421    
422            this.prevRotationPitch += this.rotationPitch - var3;
423            this.prevRotationYaw += this.rotationYaw - var4;
424        }
425    
426        /**
427         * Called to update the entity's position/logic.
428         */
429        public void onUpdate()
430        {
431            this.onEntityUpdate();
432        }
433    
434        /**
435         * Gets called every tick from main Entity class
436         */
437        public void onEntityUpdate()
438        {
439            this.worldObj.theProfiler.startSection("entityBaseTick");
440    
441            if (this.ridingEntity != null && this.ridingEntity.isDead)
442            {
443                this.ridingEntity = null;
444            }
445    
446            this.prevDistanceWalkedModified = this.distanceWalkedModified;
447            this.prevPosX = this.posX;
448            this.prevPosY = this.posY;
449            this.prevPosZ = this.posZ;
450            this.prevRotationPitch = this.rotationPitch;
451            this.prevRotationYaw = this.rotationYaw;
452            int var2;
453    
454            if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer)
455            {
456                this.worldObj.theProfiler.startSection("portal");
457                MinecraftServer var1 = ((WorldServer)this.worldObj).getMinecraftServer();
458                var2 = this.getMaxInPortalTime();
459    
460                if (this.inPortal)
461                {
462                    if (var1.getAllowNether())
463                    {
464                        if (this.ridingEntity == null && this.field_82153_h++ >= var2)
465                        {
466                            this.field_82153_h = var2;
467                            this.timeUntilPortal = this.getPortalCooldown();
468                            byte var3;
469    
470                            if (this.worldObj.provider.dimensionId == -1)
471                            {
472                                var3 = 0;
473                            }
474                            else
475                            {
476                                var3 = -1;
477                            }
478    
479                            this.travelToDimension(var3);
480                        }
481    
482                        this.inPortal = false;
483                    }
484                }
485                else
486                {
487                    if (this.field_82153_h > 0)
488                    {
489                        this.field_82153_h -= 4;
490                    }
491    
492                    if (this.field_82153_h < 0)
493                    {
494                        this.field_82153_h = 0;
495                    }
496                }
497    
498                if (this.timeUntilPortal > 0)
499                {
500                    --this.timeUntilPortal;
501                }
502    
503                this.worldObj.theProfiler.endSection();
504            }
505    
506            if (this.isSprinting() && !this.isInWater())
507            {
508                int var5 = MathHelper.floor_double(this.posX);
509                var2 = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);
510                int var6 = MathHelper.floor_double(this.posZ);
511                int var4 = this.worldObj.getBlockId(var5, var2, var6);
512    
513                if (var4 > 0)
514                {
515                    this.worldObj.spawnParticle("tilecrack_" + var4 + "_" + this.worldObj.getBlockMetadata(var5, var2, var6), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, -this.motionX * 4.0D, 1.5D, -this.motionZ * 4.0D);
516                }
517            }
518    
519            this.handleWaterMovement();
520    
521            if (this.worldObj.isRemote)
522            {
523                this.fire = 0;
524            }
525            else if (this.fire > 0)
526            {
527                if (this.isImmuneToFire)
528                {
529                    this.fire -= 4;
530    
531                    if (this.fire < 0)
532                    {
533                        this.fire = 0;
534                    }
535                }
536                else
537                {
538                    if (this.fire % 20 == 0)
539                    {
540                        this.attackEntityFrom(DamageSource.onFire, 1);
541                    }
542    
543                    --this.fire;
544                }
545            }
546    
547            if (this.handleLavaMovement())
548            {
549                this.setOnFireFromLava();
550                this.fallDistance *= 0.5F;
551            }
552    
553            if (this.posY < -64.0D)
554            {
555                this.kill();
556            }
557    
558            if (!this.worldObj.isRemote)
559            {
560                this.setFlag(0, this.fire > 0);
561                this.setFlag(2, this.ridingEntity != null && ridingEntity.shouldRiderSit());
562            }
563    
564            this.firstUpdate = false;
565            this.worldObj.theProfiler.endSection();
566        }
567    
568        /**
569         * Return the amount of time this entity should stay in a portal before being transported.
570         */
571        public int getMaxInPortalTime()
572        {
573            return 0;
574        }
575    
576        /**
577         * Called whenever the entity is walking inside of lava.
578         */
579        protected void setOnFireFromLava()
580        {
581            if (!this.isImmuneToFire)
582            {
583                this.attackEntityFrom(DamageSource.lava, 4);
584                this.setFire(15);
585            }
586        }
587    
588        /**
589         * Sets entity to burn for x amount of seconds, cannot lower amount of existing fire.
590         */
591        public void setFire(int par1)
592        {
593            int var2 = par1 * 20;
594            var2 = EnchantmentProtection.func_92041_a(this, var2);
595    
596            if (this.fire < var2)
597            {
598                this.fire = var2;
599            }
600        }
601    
602        /**
603         * Removes fire from entity.
604         */
605        public void extinguish()
606        {
607            this.fire = 0;
608        }
609    
610        /**
611         * sets the dead flag. Used when you fall off the bottom of the world.
612         */
613        protected void kill()
614        {
615            this.setDead();
616        }
617    
618        /**
619         * Checks if the offset position from the entity's current position is inside of liquid. Args: x, y, z
620         */
621        public boolean isOffsetPositionInLiquid(double par1, double par3, double par5)
622        {
623            AxisAlignedBB var7 = this.boundingBox.getOffsetBoundingBox(par1, par3, par5);
624            List var8 = this.worldObj.getCollidingBoundingBoxes(this, var7);
625            return !var8.isEmpty() ? false : !this.worldObj.isAnyLiquid(var7);
626        }
627    
628        /**
629         * Tries to moves the entity by the passed in displacement. Args: x, y, z
630         */
631        public void moveEntity(double par1, double par3, double par5)
632        {
633            if (this.noClip)
634            {
635                this.boundingBox.offset(par1, par3, par5);
636                this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D;
637                this.posY = this.boundingBox.minY + (double)this.yOffset - (double)this.ySize;
638                this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D;
639            }
640            else
641            {
642                this.worldObj.theProfiler.startSection("move");
643                this.ySize *= 0.4F;
644                double var7 = this.posX;
645                double var9 = this.posY;
646                double var11 = this.posZ;
647    
648                if (this.isInWeb)
649                {
650                    this.isInWeb = false;
651                    par1 *= 0.25D;
652                    par3 *= 0.05000000074505806D;
653                    par5 *= 0.25D;
654                    this.motionX = 0.0D;
655                    this.motionY = 0.0D;
656                    this.motionZ = 0.0D;
657                }
658    
659                double var13 = par1;
660                double var15 = par3;
661                double var17 = par5;
662                AxisAlignedBB var19 = this.boundingBox.copy();
663                boolean var20 = this.onGround && this.isSneaking() && this instanceof EntityPlayer;
664    
665                if (var20)
666                {
667                    double var21;
668    
669                    for (var21 = 0.05D; par1 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(par1, -1.0D, 0.0D)).isEmpty(); var13 = par1)
670                    {
671                        if (par1 < var21 && par1 >= -var21)
672                        {
673                            par1 = 0.0D;
674                        }
675                        else if (par1 > 0.0D)
676                        {
677                            par1 -= var21;
678                        }
679                        else
680                        {
681                            par1 += var21;
682                        }
683                    }
684    
685                    for (; par5 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(0.0D, -1.0D, par5)).isEmpty(); var17 = par5)
686                    {
687                        if (par5 < var21 && par5 >= -var21)
688                        {
689                            par5 = 0.0D;
690                        }
691                        else if (par5 > 0.0D)
692                        {
693                            par5 -= var21;
694                        }
695                        else
696                        {
697                            par5 += var21;
698                        }
699                    }
700    
701                    while (par1 != 0.0D && par5 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(par1, -1.0D, par5)).isEmpty())
702                    {
703                        if (par1 < var21 && par1 >= -var21)
704                        {
705                            par1 = 0.0D;
706                        }
707                        else if (par1 > 0.0D)
708                        {
709                            par1 -= var21;
710                        }
711                        else
712                        {
713                            par1 += var21;
714                        }
715    
716                        if (par5 < var21 && par5 >= -var21)
717                        {
718                            par5 = 0.0D;
719                        }
720                        else if (par5 > 0.0D)
721                        {
722                            par5 -= var21;
723                        }
724                        else
725                        {
726                            par5 += var21;
727                        }
728    
729                        var13 = par1;
730                        var17 = par5;
731                    }
732                }
733    
734                List var35 = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.addCoord(par1, par3, par5));
735    
736                for (int var22 = 0; var22 < var35.size(); ++var22)
737                {
738                    par3 = ((AxisAlignedBB)var35.get(var22)).calculateYOffset(this.boundingBox, par3);
739                }
740    
741                this.boundingBox.offset(0.0D, par3, 0.0D);
742    
743                if (!this.field_70135_K && var15 != par3)
744                {
745                    par5 = 0.0D;
746                    par3 = 0.0D;
747                    par1 = 0.0D;
748                }
749    
750                boolean var34 = this.onGround || var15 != par3 && var15 < 0.0D;
751                int var23;
752    
753                for (var23 = 0; var23 < var35.size(); ++var23)
754                {
755                    par1 = ((AxisAlignedBB)var35.get(var23)).calculateXOffset(this.boundingBox, par1);
756                }
757    
758                this.boundingBox.offset(par1, 0.0D, 0.0D);
759    
760                if (!this.field_70135_K && var13 != par1)
761                {
762                    par5 = 0.0D;
763                    par3 = 0.0D;
764                    par1 = 0.0D;
765                }
766    
767                for (var23 = 0; var23 < var35.size(); ++var23)
768                {
769                    par5 = ((AxisAlignedBB)var35.get(var23)).calculateZOffset(this.boundingBox, par5);
770                }
771    
772                this.boundingBox.offset(0.0D, 0.0D, par5);
773    
774                if (!this.field_70135_K && var17 != par5)
775                {
776                    par5 = 0.0D;
777                    par3 = 0.0D;
778                    par1 = 0.0D;
779                }
780    
781                double var25;
782                double var27;
783                int var30;
784                double var36;
785    
786                if (this.stepHeight > 0.0F && var34 && (var20 || this.ySize < 0.05F) && (var13 != par1 || var17 != par5))
787                {
788                    var36 = par1;
789                    var25 = par3;
790                    var27 = par5;
791                    par1 = var13;
792                    par3 = (double)this.stepHeight;
793                    par5 = var17;
794                    AxisAlignedBB var29 = this.boundingBox.copy();
795                    this.boundingBox.setBB(var19);
796                    var35 = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.addCoord(var13, par3, var17));
797    
798                    for (var30 = 0; var30 < var35.size(); ++var30)
799                    {
800                        par3 = ((AxisAlignedBB)var35.get(var30)).calculateYOffset(this.boundingBox, par3);
801                    }
802    
803                    this.boundingBox.offset(0.0D, par3, 0.0D);
804    
805                    if (!this.field_70135_K && var15 != par3)
806                    {
807                        par5 = 0.0D;
808                        par3 = 0.0D;
809                        par1 = 0.0D;
810                    }
811    
812                    for (var30 = 0; var30 < var35.size(); ++var30)
813                    {
814                        par1 = ((AxisAlignedBB)var35.get(var30)).calculateXOffset(this.boundingBox, par1);
815                    }
816    
817                    this.boundingBox.offset(par1, 0.0D, 0.0D);
818    
819                    if (!this.field_70135_K && var13 != par1)
820                    {
821                        par5 = 0.0D;
822                        par3 = 0.0D;
823                        par1 = 0.0D;
824                    }
825    
826                    for (var30 = 0; var30 < var35.size(); ++var30)
827                    {
828                        par5 = ((AxisAlignedBB)var35.get(var30)).calculateZOffset(this.boundingBox, par5);
829                    }
830    
831                    this.boundingBox.offset(0.0D, 0.0D, par5);
832    
833                    if (!this.field_70135_K && var17 != par5)
834                    {
835                        par5 = 0.0D;
836                        par3 = 0.0D;
837                        par1 = 0.0D;
838                    }
839    
840                    if (!this.field_70135_K && var15 != par3)
841                    {
842                        par5 = 0.0D;
843                        par3 = 0.0D;
844                        par1 = 0.0D;
845                    }
846                    else
847                    {
848                        par3 = (double)(-this.stepHeight);
849    
850                        for (var30 = 0; var30 < var35.size(); ++var30)
851                        {
852                            par3 = ((AxisAlignedBB)var35.get(var30)).calculateYOffset(this.boundingBox, par3);
853                        }
854    
855                        this.boundingBox.offset(0.0D, par3, 0.0D);
856                    }
857    
858                    if (var36 * var36 + var27 * var27 >= par1 * par1 + par5 * par5)
859                    {
860                        par1 = var36;
861                        par3 = var25;
862                        par5 = var27;
863                        this.boundingBox.setBB(var29);
864                    }
865                    else
866                    {
867                        double var40 = this.boundingBox.minY - (double)((int)this.boundingBox.minY);
868    
869                        if (var40 > 0.0D)
870                        {
871                            this.ySize = (float)((double)this.ySize + var40 + 0.01D);
872                        }
873                    }
874                }
875    
876                this.worldObj.theProfiler.endSection();
877                this.worldObj.theProfiler.startSection("rest");
878                this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D;
879                this.posY = this.boundingBox.minY + (double)this.yOffset - (double)this.ySize;
880                this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D;
881                this.isCollidedHorizontally = var13 != par1 || var17 != par5;
882                this.isCollidedVertically = var15 != par3;
883                this.onGround = var15 != par3 && var15 < 0.0D;
884                this.isCollided = this.isCollidedHorizontally || this.isCollidedVertically;
885                this.updateFallState(par3, this.onGround);
886    
887                if (var13 != par1)
888                {
889                    this.motionX = 0.0D;
890                }
891    
892                if (var15 != par3)
893                {
894                    this.motionY = 0.0D;
895                }
896    
897                if (var17 != par5)
898                {
899                    this.motionZ = 0.0D;
900                }
901    
902                var36 = this.posX - var7;
903                var25 = this.posY - var9;
904                var27 = this.posZ - var11;
905    
906                if (this.canTriggerWalking() && !var20 && this.ridingEntity == null)
907                {
908                    int var37 = MathHelper.floor_double(this.posX);
909                    var30 = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);
910                    int var31 = MathHelper.floor_double(this.posZ);
911                    int var32 = this.worldObj.getBlockId(var37, var30, var31);
912    
913                    if (var32 == 0)
914                    {
915                        int var33 = this.worldObj.func_85175_e(var37, var30 - 1, var31);
916    
917                        if (var33 == 11 || var33 == 32 || var33 == 21)
918                        {
919                            var32 = this.worldObj.getBlockId(var37, var30 - 1, var31);
920                        }
921                    }
922    
923                    if (var32 != Block.ladder.blockID)
924                    {
925                        var25 = 0.0D;
926                    }
927    
928                    this.distanceWalkedModified = (float)((double)this.distanceWalkedModified + (double)MathHelper.sqrt_double(var36 * var36 + var27 * var27) * 0.6D);
929                    this.field_82151_R = (float)((double)this.field_82151_R + (double)MathHelper.sqrt_double(var36 * var36 + var25 * var25 + var27 * var27) * 0.6D);
930    
931                    if (this.field_82151_R > (float)this.nextStepDistance && var32 > 0)
932                    {
933                        this.nextStepDistance = (int)this.field_82151_R + 1;
934    
935                        if (this.isInWater())
936                        {
937                            float var39 = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.35F;
938    
939                            if (var39 > 1.0F)
940                            {
941                                var39 = 1.0F;
942                            }
943    
944                            this.func_85030_a("liquid.swim", var39, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
945                        }
946    
947                        this.playStepSound(var37, var30, var31, var32);
948                        Block.blocksList[var32].onEntityWalking(this.worldObj, var37, var30, var31, this);
949                    }
950                }
951    
952                this.doBlockCollisions();
953                boolean var38 = this.isWet();
954    
955                if (this.worldObj.isBoundingBoxBurning(this.boundingBox.contract(0.001D, 0.001D, 0.001D)))
956                {
957                    this.dealFireDamage(1);
958    
959                    if (!var38)
960                    {
961                        ++this.fire;
962    
963                        if (this.fire == 0)
964                        {
965                            this.setFire(8);
966                        }
967                    }
968                }
969                else if (this.fire <= 0)
970                {
971                    this.fire = -this.fireResistance;
972                }
973    
974                if (var38 && this.fire > 0)
975                {
976                    this.func_85030_a("random.fizz", 0.7F, 1.6F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
977                    this.fire = -this.fireResistance;
978                }
979    
980                this.worldObj.theProfiler.endSection();
981            }
982        }
983    
984        /**
985         * Checks for block collisions, and calls the associated onBlockCollided method for the collided block.
986         */
987        protected void doBlockCollisions()
988        {
989            int var1 = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
990            int var2 = MathHelper.floor_double(this.boundingBox.minY + 0.001D);
991            int var3 = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
992            int var4 = MathHelper.floor_double(this.boundingBox.maxX - 0.001D);
993            int var5 = MathHelper.floor_double(this.boundingBox.maxY - 0.001D);
994            int var6 = MathHelper.floor_double(this.boundingBox.maxZ - 0.001D);
995    
996            if (this.worldObj.checkChunksExist(var1, var2, var3, var4, var5, var6))
997            {
998                for (int var7 = var1; var7 <= var4; ++var7)
999                {
1000                    for (int var8 = var2; var8 <= var5; ++var8)
1001                    {
1002                        for (int var9 = var3; var9 <= var6; ++var9)
1003                        {
1004                            int var10 = this.worldObj.getBlockId(var7, var8, var9);
1005    
1006                            if (var10 > 0)
1007                            {
1008                                Block.blocksList[var10].onEntityCollidedWithBlock(this.worldObj, var7, var8, var9, this);
1009                            }
1010                        }
1011                    }
1012                }
1013            }
1014        }
1015    
1016        /**
1017         * Plays step sound at given x, y, z for the entity
1018         */
1019        protected void playStepSound(int par1, int par2, int par3, int par4)
1020        {
1021            StepSound var5 = Block.blocksList[par4].stepSound;
1022    
1023            if (this.worldObj.getBlockId(par1, par2 + 1, par3) == Block.snow.blockID)
1024            {
1025                var5 = Block.snow.stepSound;
1026                this.func_85030_a(var5.getStepSound(), var5.getVolume() * 0.15F, var5.getPitch());
1027            }
1028            else if (!Block.blocksList[par4].blockMaterial.isLiquid())
1029            {
1030                this.func_85030_a(var5.getStepSound(), var5.getVolume() * 0.15F, var5.getPitch());
1031            }
1032        }
1033    
1034        public void func_85030_a(String par1Str, float par2, float par3)
1035        {
1036            this.worldObj.playSoundAtEntity(this, par1Str, par2, par3);
1037        }
1038    
1039        /**
1040         * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
1041         * prevent them from trampling crops
1042         */
1043        protected boolean canTriggerWalking()
1044        {
1045            return true;
1046        }
1047    
1048        /**
1049         * Takes in the distance the entity has fallen this tick and whether its on the ground to update the fall distance
1050         * and deal fall damage if landing on the ground.  Args: distanceFallenThisTick, onGround
1051         */
1052        protected void updateFallState(double par1, boolean par3)
1053        {
1054            if (par3)
1055            {
1056                if (this.fallDistance > 0.0F)
1057                {
1058                    this.fall(this.fallDistance);
1059                    this.fallDistance = 0.0F;
1060                }
1061            }
1062            else if (par1 < 0.0D)
1063            {
1064                this.fallDistance = (float)((double)this.fallDistance - par1);
1065            }
1066        }
1067    
1068        /**
1069         * returns the bounding box for this entity
1070         */
1071        public AxisAlignedBB getBoundingBox()
1072        {
1073            return null;
1074        }
1075    
1076        /**
1077         * Will deal the specified amount of damage to the entity if the entity isn't immune to fire damage. Args:
1078         * amountDamage
1079         */
1080        protected void dealFireDamage(int par1)
1081        {
1082            if (!this.isImmuneToFire)
1083            {
1084                this.attackEntityFrom(DamageSource.inFire, par1);
1085            }
1086        }
1087    
1088        public final boolean isImmuneToFire()
1089        {
1090            return this.isImmuneToFire;
1091        }
1092    
1093        /**
1094         * Called when the mob is falling. Calculates and applies fall damage.
1095         */
1096        protected void fall(float par1)
1097        {
1098            if (this.riddenByEntity != null)
1099            {
1100                this.riddenByEntity.fall(par1);
1101            }
1102        }
1103    
1104        /**
1105         * Checks if this entity is either in water or on an open air block in rain (used in wolves).
1106         */
1107        public boolean isWet()
1108        {
1109            return this.inWater || this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) || this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY + (double)this.height), MathHelper.floor_double(this.posZ));
1110        }
1111    
1112        /**
1113         * Checks if this entity is inside water (if inWater field is true as a result of handleWaterMovement() returning
1114         * true)
1115         */
1116        public boolean isInWater()
1117        {
1118            return this.inWater;
1119        }
1120    
1121        /**
1122         * Returns if this entity is in water and will end up adding the waters velocity to the entity
1123         */
1124        public boolean handleWaterMovement()
1125        {
1126            if (this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D, 0.001D, 0.001D), Material.water, this))
1127            {
1128                if (!this.inWater && !this.firstUpdate)
1129                {
1130                    float var1 = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.2F;
1131    
1132                    if (var1 > 1.0F)
1133                    {
1134                        var1 = 1.0F;
1135                    }
1136    
1137                    this.func_85030_a("liquid.splash", var1, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
1138                    float var2 = (float)MathHelper.floor_double(this.boundingBox.minY);
1139                    int var3;
1140                    float var4;
1141                    float var5;
1142    
1143                    for (var3 = 0; (float)var3 < 1.0F + this.width * 20.0F; ++var3)
1144                    {
1145                        var4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1146                        var5 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1147                        this.worldObj.spawnParticle("bubble", this.posX + (double)var4, (double)(var2 + 1.0F), this.posZ + (double)var5, this.motionX, this.motionY - (double)(this.rand.nextFloat() * 0.2F), this.motionZ);
1148                    }
1149    
1150                    for (var3 = 0; (float)var3 < 1.0F + this.width * 20.0F; ++var3)
1151                    {
1152                        var4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1153                        var5 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1154                        this.worldObj.spawnParticle("splash", this.posX + (double)var4, (double)(var2 + 1.0F), this.posZ + (double)var5, this.motionX, this.motionY, this.motionZ);
1155                    }
1156                }
1157    
1158                this.fallDistance = 0.0F;
1159                this.inWater = true;
1160                this.fire = 0;
1161            }
1162            else
1163            {
1164                this.inWater = false;
1165            }
1166    
1167            return this.inWater;
1168        }
1169    
1170        /**
1171         * Checks if the current block the entity is within of the specified material type
1172         */
1173        public boolean isInsideOfMaterial(Material par1Material)
1174        {
1175            double var2 = this.posY + (double)this.getEyeHeight();
1176            int var4 = MathHelper.floor_double(this.posX);
1177            int var5 = MathHelper.floor_float((float)MathHelper.floor_double(var2));
1178            int var6 = MathHelper.floor_double(this.posZ);
1179            int var7 = this.worldObj.getBlockId(var4, var5, var6);
1180    
1181            if (var7 != 0 && Block.blocksList[var7].blockMaterial == par1Material)
1182            {
1183                float var8 = BlockFluid.getFluidHeightPercent(this.worldObj.getBlockMetadata(var4, var5, var6)) - 0.11111111F;
1184                float var9 = (float)(var5 + 1) - var8;
1185                return var2 < (double)var9;
1186            }
1187            else
1188            {
1189                return false;
1190            }
1191        }
1192    
1193        public float getEyeHeight()
1194        {
1195            return 0.0F;
1196        }
1197    
1198        /**
1199         * Whether or not the current entity is in lava
1200         */
1201        public boolean handleLavaMovement()
1202        {
1203            return this.worldObj.isMaterialInBB(this.boundingBox.expand(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.lava);
1204        }
1205    
1206        /**
1207         * Used in both water and by flying objects
1208         */
1209        public void moveFlying(float par1, float par2, float par3)
1210        {
1211            float var4 = par1 * par1 + par2 * par2;
1212    
1213            if (var4 >= 1.0E-4F)
1214            {
1215                var4 = MathHelper.sqrt_float(var4);
1216    
1217                if (var4 < 1.0F)
1218                {
1219                    var4 = 1.0F;
1220                }
1221    
1222                var4 = par3 / var4;
1223                par1 *= var4;
1224                par2 *= var4;
1225                float var5 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F);
1226                float var6 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F);
1227                this.motionX += (double)(par1 * var6 - par2 * var5);
1228                this.motionZ += (double)(par2 * var6 + par1 * var5);
1229            }
1230        }
1231    
1232        @SideOnly(Side.CLIENT)
1233        public int getBrightnessForRender(float par1)
1234        {
1235            int var2 = MathHelper.floor_double(this.posX);
1236            int var3 = MathHelper.floor_double(this.posZ);
1237    
1238            if (this.worldObj.blockExists(var2, 0, var3))
1239            {
1240                double var4 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D;
1241                int var6 = MathHelper.floor_double(this.posY - (double)this.yOffset + var4);
1242                return this.worldObj.getLightBrightnessForSkyBlocks(var2, var6, var3, 0);
1243            }
1244            else
1245            {
1246                return 0;
1247            }
1248        }
1249    
1250        /**
1251         * Gets how bright this entity is.
1252         */
1253        public float getBrightness(float par1)
1254        {
1255            int var2 = MathHelper.floor_double(this.posX);
1256            int var3 = MathHelper.floor_double(this.posZ);
1257    
1258            if (this.worldObj.blockExists(var2, 0, var3))
1259            {
1260                double var4 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D;
1261                int var6 = MathHelper.floor_double(this.posY - (double)this.yOffset + var4);
1262                return this.worldObj.getLightBrightness(var2, var6, var3);
1263            }
1264            else
1265            {
1266                return 0.0F;
1267            }
1268        }
1269    
1270        /**
1271         * Sets the reference to the World object.
1272         */
1273        public void setWorld(World par1World)
1274        {
1275            this.worldObj = par1World;
1276        }
1277    
1278        /**
1279         * Sets the entity's position and rotation. Args: posX, posY, posZ, yaw, pitch
1280         */
1281        public void setPositionAndRotation(double par1, double par3, double par5, float par7, float par8)
1282        {
1283            this.prevPosX = this.posX = par1;
1284            this.prevPosY = this.posY = par3;
1285            this.prevPosZ = this.posZ = par5;
1286            this.prevRotationYaw = this.rotationYaw = par7;
1287            this.prevRotationPitch = this.rotationPitch = par8;
1288            this.ySize = 0.0F;
1289            double var9 = (double)(this.prevRotationYaw - par7);
1290    
1291            if (var9 < -180.0D)
1292            {
1293                this.prevRotationYaw += 360.0F;
1294            }
1295    
1296            if (var9 >= 180.0D)
1297            {
1298                this.prevRotationYaw -= 360.0F;
1299            }
1300    
1301            this.setPosition(this.posX, this.posY, this.posZ);
1302            this.setRotation(par7, par8);
1303        }
1304    
1305        /**
1306         * Sets the location and Yaw/Pitch of an entity in the world
1307         */
1308        public void setLocationAndAngles(double par1, double par3, double par5, float par7, float par8)
1309        {
1310            this.lastTickPosX = this.prevPosX = this.posX = par1;
1311            this.lastTickPosY = this.prevPosY = this.posY = par3 + (double)this.yOffset;
1312            this.lastTickPosZ = this.prevPosZ = this.posZ = par5;
1313            this.rotationYaw = par7;
1314            this.rotationPitch = par8;
1315            this.setPosition(this.posX, this.posY, this.posZ);
1316        }
1317    
1318        /**
1319         * Returns the distance to the entity. Args: entity
1320         */
1321        public float getDistanceToEntity(Entity par1Entity)
1322        {
1323            float var2 = (float)(this.posX - par1Entity.posX);
1324            float var3 = (float)(this.posY - par1Entity.posY);
1325            float var4 = (float)(this.posZ - par1Entity.posZ);
1326            return MathHelper.sqrt_float(var2 * var2 + var3 * var3 + var4 * var4);
1327        }
1328    
1329        /**
1330         * Gets the squared distance to the position. Args: x, y, z
1331         */
1332        public double getDistanceSq(double par1, double par3, double par5)
1333        {
1334            double var7 = this.posX - par1;
1335            double var9 = this.posY - par3;
1336            double var11 = this.posZ - par5;
1337            return var7 * var7 + var9 * var9 + var11 * var11;
1338        }
1339    
1340        /**
1341         * Gets the distance to the position. Args: x, y, z
1342         */
1343        public double getDistance(double par1, double par3, double par5)
1344        {
1345            double var7 = this.posX - par1;
1346            double var9 = this.posY - par3;
1347            double var11 = this.posZ - par5;
1348            return (double)MathHelper.sqrt_double(var7 * var7 + var9 * var9 + var11 * var11);
1349        }
1350    
1351        /**
1352         * Returns the squared distance to the entity. Args: entity
1353         */
1354        public double getDistanceSqToEntity(Entity par1Entity)
1355        {
1356            double var2 = this.posX - par1Entity.posX;
1357            double var4 = this.posY - par1Entity.posY;
1358            double var6 = this.posZ - par1Entity.posZ;
1359            return var2 * var2 + var4 * var4 + var6 * var6;
1360        }
1361    
1362        /**
1363         * Called by a player entity when they collide with an entity
1364         */
1365        public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) {}
1366    
1367        /**
1368         * Applies a velocity to each of the entities pushing them away from each other. Args: entity
1369         */
1370        public void applyEntityCollision(Entity par1Entity)
1371        {
1372            if (par1Entity.riddenByEntity != this && par1Entity.ridingEntity != this)
1373            {
1374                double var2 = par1Entity.posX - this.posX;
1375                double var4 = par1Entity.posZ - this.posZ;
1376                double var6 = MathHelper.abs_max(var2, var4);
1377    
1378                if (var6 >= 0.009999999776482582D)
1379                {
1380                    var6 = (double)MathHelper.sqrt_double(var6);
1381                    var2 /= var6;
1382                    var4 /= var6;
1383                    double var8 = 1.0D / var6;
1384    
1385                    if (var8 > 1.0D)
1386                    {
1387                        var8 = 1.0D;
1388                    }
1389    
1390                    var2 *= var8;
1391                    var4 *= var8;
1392                    var2 *= 0.05000000074505806D;
1393                    var4 *= 0.05000000074505806D;
1394                    var2 *= (double)(1.0F - this.entityCollisionReduction);
1395                    var4 *= (double)(1.0F - this.entityCollisionReduction);
1396                    this.addVelocity(-var2, 0.0D, -var4);
1397                    par1Entity.addVelocity(var2, 0.0D, var4);
1398                }
1399            }
1400        }
1401    
1402        /**
1403         * Adds to the current velocity of the entity. Args: x, y, z
1404         */
1405        public void addVelocity(double par1, double par3, double par5)
1406        {
1407            this.motionX += par1;
1408            this.motionY += par3;
1409            this.motionZ += par5;
1410            this.isAirBorne = true;
1411        }
1412    
1413        /**
1414         * Sets that this entity has been attacked.
1415         */
1416        protected void setBeenAttacked()
1417        {
1418            this.velocityChanged = true;
1419        }
1420    
1421        /**
1422         * Called when the entity is attacked.
1423         */
1424        public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
1425        {
1426            if (this.func_85032_ar())
1427            {
1428                return false;
1429            }
1430            else
1431            {
1432                this.setBeenAttacked();
1433                return false;
1434            }
1435        }
1436    
1437        /**
1438         * Returns true if other Entities should be prevented from moving through this Entity.
1439         */
1440        public boolean canBeCollidedWith()
1441        {
1442            return false;
1443        }
1444    
1445        /**
1446         * Returns true if this entity should push and be pushed by other entities when colliding.
1447         */
1448        public boolean canBePushed()
1449        {
1450            return false;
1451        }
1452    
1453        /**
1454         * Adds a value to the player score. Currently not actually used and the entity passed in does nothing. Args:
1455         * entity, scoreToAdd
1456         */
1457        public void addToPlayerScore(Entity par1Entity, int par2) {}
1458    
1459        /**
1460         * adds the ID of this entity to the NBT given
1461         */
1462        public boolean addEntityID(NBTTagCompound par1NBTTagCompound)
1463        {
1464            String var2 = this.getEntityString();
1465    
1466            if (!this.isDead && var2 != null)
1467            {
1468                par1NBTTagCompound.setString("id", var2);
1469                this.writeToNBT(par1NBTTagCompound);
1470                return true;
1471            }
1472            else
1473            {
1474                return false;
1475            }
1476        }
1477    
1478        @SideOnly(Side.CLIENT)
1479    
1480        /**
1481         * Checks using a Vec3d to determine if this entity is within range of that vector to be rendered. Args: vec3D
1482         */
1483        public boolean isInRangeToRenderVec3D(Vec3 par1Vec3)
1484        {
1485            double var2 = this.posX - par1Vec3.xCoord;
1486            double var4 = this.posY - par1Vec3.yCoord;
1487            double var6 = this.posZ - par1Vec3.zCoord;
1488            double var8 = var2 * var2 + var4 * var4 + var6 * var6;
1489            return this.isInRangeToRenderDist(var8);
1490        }
1491    
1492        @SideOnly(Side.CLIENT)
1493    
1494        /**
1495         * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
1496         * length * 64 * renderDistanceWeight Args: distance
1497         */
1498        public boolean isInRangeToRenderDist(double par1)
1499        {
1500            double var3 = this.boundingBox.getAverageEdgeLength();
1501            var3 *= 64.0D * this.renderDistanceWeight;
1502            return par1 < var3 * var3;
1503        }
1504    
1505        @SideOnly(Side.CLIENT)
1506    
1507        /**
1508         * Returns the texture's file path as a String.
1509         */
1510        public String getTexture()
1511        {
1512            return null;
1513        }
1514    
1515        /**
1516         * Save the entity to NBT (calls an abstract helper method to write extra data)
1517         */
1518        public void writeToNBT(NBTTagCompound par1NBTTagCompound)
1519        {
1520            try
1521            {
1522                par1NBTTagCompound.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ}));
1523                par1NBTTagCompound.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
1524                par1NBTTagCompound.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch}));
1525                par1NBTTagCompound.setFloat("FallDistance", this.fallDistance);
1526                par1NBTTagCompound.setShort("Fire", (short)this.fire);
1527                par1NBTTagCompound.setShort("Air", (short)this.getAir());
1528                par1NBTTagCompound.setBoolean("OnGround", this.onGround);
1529                par1NBTTagCompound.setInteger("Dimension", this.dimension);
1530                par1NBTTagCompound.setBoolean("Invulnerable", this.field_83001_bt);
1531                par1NBTTagCompound.setInteger("PortalCooldown", this.timeUntilPortal);
1532                if (persistentID != null)
1533                {
1534                    par1NBTTagCompound.setLong("PersistentIDMSB", persistentID.getMostSignificantBits());
1535                    par1NBTTagCompound.setLong("PersistentIDLSB", persistentID.getLeastSignificantBits());
1536                }
1537                if (customEntityData != null)
1538                {
1539                    par1NBTTagCompound.setCompoundTag("ForgeData", customEntityData);
1540                }
1541                this.writeEntityToNBT(par1NBTTagCompound);
1542            }
1543            catch (Throwable var5)
1544            {
1545                CrashReport var3 = CrashReport.makeCrashReport(var5, "Saving entity NBT");
1546                CrashReportCategory var4 = var3.makeCategory("Entity being saved");
1547                this.func_85029_a(var4);
1548                throw new ReportedException(var3);
1549            }
1550        }
1551    
1552        /**
1553         * Reads the entity from NBT (calls an abstract helper method to read specialized data)
1554         */
1555        public void readFromNBT(NBTTagCompound par1NBTTagCompound)
1556        {
1557            try
1558            {
1559                NBTTagList var2 = par1NBTTagCompound.getTagList("Pos");
1560                NBTTagList var6 = par1NBTTagCompound.getTagList("Motion");
1561                NBTTagList var7 = par1NBTTagCompound.getTagList("Rotation");
1562                this.motionX = ((NBTTagDouble)var6.tagAt(0)).data;
1563                this.motionY = ((NBTTagDouble)var6.tagAt(1)).data;
1564                this.motionZ = ((NBTTagDouble)var6.tagAt(2)).data;
1565    
1566                if (Math.abs(this.motionX) > 10.0D)
1567                {
1568                    this.motionX = 0.0D;
1569                }
1570    
1571                if (Math.abs(this.motionY) > 10.0D)
1572                {
1573                    this.motionY = 0.0D;
1574                }
1575    
1576                if (Math.abs(this.motionZ) > 10.0D)
1577                {
1578                    this.motionZ = 0.0D;
1579                }
1580    
1581                this.prevPosX = this.lastTickPosX = this.posX = ((NBTTagDouble)var2.tagAt(0)).data;
1582                this.prevPosY = this.lastTickPosY = this.posY = ((NBTTagDouble)var2.tagAt(1)).data;
1583                this.prevPosZ = this.lastTickPosZ = this.posZ = ((NBTTagDouble)var2.tagAt(2)).data;
1584                this.prevRotationYaw = this.rotationYaw = ((NBTTagFloat)var7.tagAt(0)).data;
1585                this.prevRotationPitch = this.rotationPitch = ((NBTTagFloat)var7.tagAt(1)).data;
1586                this.fallDistance = par1NBTTagCompound.getFloat("FallDistance");
1587                this.fire = par1NBTTagCompound.getShort("Fire");
1588                this.setAir(par1NBTTagCompound.getShort("Air"));
1589                this.onGround = par1NBTTagCompound.getBoolean("OnGround");
1590                this.dimension = par1NBTTagCompound.getInteger("Dimension");
1591                this.field_83001_bt = par1NBTTagCompound.getBoolean("Invulnerable");
1592                this.timeUntilPortal = par1NBTTagCompound.getInteger("PortalCooldown");
1593                this.setPosition(this.posX, this.posY, this.posZ);
1594                this.setRotation(this.rotationYaw, this.rotationPitch);
1595                if (par1NBTTagCompound.hasKey("ForgeData"))
1596                {
1597                    customEntityData = par1NBTTagCompound.getCompoundTag("ForgeData");
1598                }
1599                if (par1NBTTagCompound.hasKey("PersistentIDMSB") && par1NBTTagCompound.hasKey("PersistentIDLSB"))
1600                {
1601                    persistentID = new UUID(par1NBTTagCompound.getLong("PersistentIDMSB"), par1NBTTagCompound.getLong("PersistentIDLSB"));
1602                }
1603                this.readEntityFromNBT(par1NBTTagCompound);
1604            }
1605            catch (Throwable var5)
1606            {
1607                CrashReport var3 = CrashReport.makeCrashReport(var5, "Loading entity NBT");
1608                CrashReportCategory var4 = var3.makeCategory("Entity being loaded");
1609                this.func_85029_a(var4);
1610                throw new ReportedException(var3);
1611            }
1612        }
1613    
1614        /**
1615         * Returns the string that identifies this Entity's class
1616         */
1617        protected final String getEntityString()
1618        {
1619            return EntityList.getEntityString(this);
1620        }
1621    
1622        /**
1623         * (abstract) Protected helper method to read subclass entity data from NBT.
1624         */
1625        protected abstract void readEntityFromNBT(NBTTagCompound var1);
1626    
1627        /**
1628         * (abstract) Protected helper method to write subclass entity data to NBT.
1629         */
1630        protected abstract void writeEntityToNBT(NBTTagCompound var1);
1631    
1632        /**
1633         * creates a NBT list from the array of doubles passed to this function
1634         */
1635        protected NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble)
1636        {
1637            NBTTagList var2 = new NBTTagList();
1638            double[] var3 = par1ArrayOfDouble;
1639            int var4 = par1ArrayOfDouble.length;
1640    
1641            for (int var5 = 0; var5 < var4; ++var5)
1642            {
1643                double var6 = var3[var5];
1644                var2.appendTag(new NBTTagDouble((String)null, var6));
1645            }
1646    
1647            return var2;
1648        }
1649    
1650        /**
1651         * Returns a new NBTTagList filled with the specified floats
1652         */
1653        protected NBTTagList newFloatNBTList(float ... par1ArrayOfFloat)
1654        {
1655            NBTTagList var2 = new NBTTagList();
1656            float[] var3 = par1ArrayOfFloat;
1657            int var4 = par1ArrayOfFloat.length;
1658    
1659            for (int var5 = 0; var5 < var4; ++var5)
1660            {
1661                float var6 = var3[var5];
1662                var2.appendTag(new NBTTagFloat((String)null, var6));
1663            }
1664    
1665            return var2;
1666        }
1667    
1668        @SideOnly(Side.CLIENT)
1669        public float getShadowSize()
1670        {
1671            return this.height / 2.0F;
1672        }
1673    
1674        /**
1675         * Drops an item stack at the entity's position. Args: itemID, count
1676         */
1677        public EntityItem dropItem(int par1, int par2)
1678        {
1679            return this.dropItemWithOffset(par1, par2, 0.0F);
1680        }
1681    
1682        /**
1683         * Drops an item stack with a specified y offset. Args: itemID, count, yOffset
1684         */
1685        public EntityItem dropItemWithOffset(int par1, int par2, float par3)
1686        {
1687            return this.entityDropItem(new ItemStack(par1, par2, 0), par3);
1688        }
1689    
1690        /**
1691         * Drops an item at the position of the entity.
1692         */
1693        public EntityItem entityDropItem(ItemStack par1ItemStack, float par2)
1694        {
1695            EntityItem var3 = new EntityItem(this.worldObj, this.posX, this.posY + (double)par2, this.posZ, par1ItemStack);
1696            var3.delayBeforeCanPickup = 10;
1697            if (captureDrops)
1698            {
1699                capturedDrops.add(var3);
1700            }
1701            else
1702            {
1703                this.worldObj.spawnEntityInWorld(var3);
1704            }
1705            return var3;
1706        }
1707    
1708        /**
1709         * Checks whether target entity is alive.
1710         */
1711        public boolean isEntityAlive()
1712        {
1713            return !this.isDead;
1714        }
1715    
1716        /**
1717         * Checks if this entity is inside of an opaque block
1718         */
1719        public boolean isEntityInsideOpaqueBlock()
1720        {
1721            for (int var1 = 0; var1 < 8; ++var1)
1722            {
1723                float var2 = ((float)((var1 >> 0) % 2) - 0.5F) * this.width * 0.8F;
1724                float var3 = ((float)((var1 >> 1) % 2) - 0.5F) * 0.1F;
1725                float var4 = ((float)((var1 >> 2) % 2) - 0.5F) * this.width * 0.8F;
1726                int var5 = MathHelper.floor_double(this.posX + (double)var2);
1727                int var6 = MathHelper.floor_double(this.posY + (double)this.getEyeHeight() + (double)var3);
1728                int var7 = MathHelper.floor_double(this.posZ + (double)var4);
1729    
1730                if (this.worldObj.isBlockNormalCube(var5, var6, var7))
1731                {
1732                    return true;
1733                }
1734            }
1735    
1736            return false;
1737        }
1738    
1739        /**
1740         * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
1741         */
1742        public boolean interact(EntityPlayer par1EntityPlayer)
1743        {
1744            return false;
1745        }
1746    
1747        /**
1748         * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be
1749         * pushable on contact, like boats or minecarts.
1750         */
1751        public AxisAlignedBB getCollisionBox(Entity par1Entity)
1752        {
1753            return null;
1754        }
1755    
1756        /**
1757         * Handles updating while being ridden by an entity
1758         */
1759        public void updateRidden()
1760        {
1761            if (this.ridingEntity.isDead)
1762            {
1763                this.ridingEntity = null;
1764            }
1765            else
1766            {
1767                this.motionX = 0.0D;
1768                this.motionY = 0.0D;
1769                this.motionZ = 0.0D;
1770                this.onUpdate();
1771    
1772                if (this.ridingEntity != null)
1773                {
1774                    this.ridingEntity.updateRiderPosition();
1775                    this.entityRiderYawDelta += (double)(this.ridingEntity.rotationYaw - this.ridingEntity.prevRotationYaw);
1776    
1777                    for (this.entityRiderPitchDelta += (double)(this.ridingEntity.rotationPitch - this.ridingEntity.prevRotationPitch); this.entityRiderYawDelta >= 180.0D; this.entityRiderYawDelta -= 360.0D)
1778                    {
1779                        ;
1780                    }
1781    
1782                    while (this.entityRiderYawDelta < -180.0D)
1783                    {
1784                        this.entityRiderYawDelta += 360.0D;
1785                    }
1786    
1787                    while (this.entityRiderPitchDelta >= 180.0D)
1788                    {
1789                        this.entityRiderPitchDelta -= 360.0D;
1790                    }
1791    
1792                    while (this.entityRiderPitchDelta < -180.0D)
1793                    {
1794                        this.entityRiderPitchDelta += 360.0D;
1795                    }
1796    
1797                    double var1 = this.entityRiderYawDelta * 0.5D;
1798                    double var3 = this.entityRiderPitchDelta * 0.5D;
1799                    float var5 = 10.0F;
1800    
1801                    if (var1 > (double)var5)
1802                    {
1803                        var1 = (double)var5;
1804                    }
1805    
1806                    if (var1 < (double)(-var5))
1807                    {
1808                        var1 = (double)(-var5);
1809                    }
1810    
1811                    if (var3 > (double)var5)
1812                    {
1813                        var3 = (double)var5;
1814                    }
1815    
1816                    if (var3 < (double)(-var5))
1817                    {
1818                        var3 = (double)(-var5);
1819                    }
1820    
1821                    this.entityRiderYawDelta -= var1;
1822                    this.entityRiderPitchDelta -= var3;
1823                    this.rotationYaw = (float)((double)this.rotationYaw + var1);
1824                    this.rotationPitch = (float)((double)this.rotationPitch + var3);
1825                }
1826            }
1827        }
1828    
1829        public void updateRiderPosition()
1830        {
1831            if (!(this.riddenByEntity instanceof EntityPlayer) || !((EntityPlayer)this.riddenByEntity).func_71066_bF())
1832            {
1833                this.riddenByEntity.lastTickPosX = this.lastTickPosX;
1834                this.riddenByEntity.lastTickPosY = this.lastTickPosY + this.getMountedYOffset() + this.riddenByEntity.getYOffset();
1835                this.riddenByEntity.lastTickPosZ = this.lastTickPosZ;
1836            }
1837    
1838            this.riddenByEntity.setPosition(this.posX, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ);
1839        }
1840    
1841        /**
1842         * Returns the Y Offset of this entity.
1843         */
1844        public double getYOffset()
1845        {
1846            return (double)this.yOffset;
1847        }
1848    
1849        /**
1850         * Returns the Y offset from the entity's position for any entity riding this one.
1851         */
1852        public double getMountedYOffset()
1853        {
1854            return (double)this.height * 0.75D;
1855        }
1856    
1857        /**
1858         * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
1859         */
1860        public void mountEntity(Entity par1Entity)
1861        {
1862            this.entityRiderPitchDelta = 0.0D;
1863            this.entityRiderYawDelta = 0.0D;
1864    
1865            if (par1Entity == null)
1866            {
1867                if (this.ridingEntity != null)
1868                {
1869                    this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch);
1870                    this.ridingEntity.riddenByEntity = null;
1871                }
1872    
1873                this.ridingEntity = null;
1874            }
1875            else if (this.ridingEntity == par1Entity)
1876            {
1877                this.unmountEntity(par1Entity);
1878                this.ridingEntity.riddenByEntity = null;
1879                this.ridingEntity = null;
1880            }
1881            else
1882            {
1883                if (this.ridingEntity != null)
1884                {
1885                    this.ridingEntity.riddenByEntity = null;
1886                }
1887    
1888                if (par1Entity.riddenByEntity != null)
1889                {
1890                    par1Entity.riddenByEntity.ridingEntity = null;
1891                }
1892    
1893                this.ridingEntity = par1Entity;
1894                par1Entity.riddenByEntity = this;
1895            }
1896        }
1897    
1898        /**
1899         * Called when a player unounts an entity.
1900         */
1901        public void unmountEntity(Entity par1Entity)
1902        {
1903            double var3 = par1Entity.posX;
1904            double var5 = par1Entity.boundingBox.minY + (double)par1Entity.height;
1905            double var7 = par1Entity.posZ;
1906    
1907            for (double var9 = -1.5D; var9 < 2.0D; ++var9)
1908            {
1909                for (double var11 = -1.5D; var11 < 2.0D; ++var11)
1910                {
1911                    if (var9 != 0.0D || var11 != 0.0D)
1912                    {
1913                        int var13 = (int)(this.posX + var9);
1914                        int var14 = (int)(this.posZ + var11);
1915                        AxisAlignedBB var2 = this.boundingBox.getOffsetBoundingBox(var9, 1.0D, var11);
1916    
1917                        if (this.worldObj.getAllCollidingBoundingBoxes(var2).isEmpty())
1918                        {
1919                            if (this.worldObj.doesBlockHaveSolidTopSurface(var13, (int)this.posY, var14))
1920                            {
1921                                this.setLocationAndAngles(this.posX + var9, this.posY + 1.0D, this.posZ + var11, this.rotationYaw, this.rotationPitch);
1922                                return;
1923                            }
1924    
1925                            if (this.worldObj.doesBlockHaveSolidTopSurface(var13, (int)this.posY - 1, var14) || this.worldObj.getBlockMaterial(var13, (int)this.posY - 1, var14) == Material.water)
1926                            {
1927                                var3 = this.posX + var9;
1928                                var5 = this.posY + 1.0D;
1929                                var7 = this.posZ + var11;
1930                            }
1931                        }
1932                    }
1933                }
1934            }
1935    
1936            this.setLocationAndAngles(var3, var5, var7, this.rotationYaw, this.rotationPitch);
1937        }
1938    
1939        @SideOnly(Side.CLIENT)
1940    
1941        /**
1942         * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
1943         * posY, posZ, yaw, pitch
1944         */
1945        public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
1946        {
1947            this.setPosition(par1, par3, par5);
1948            this.setRotation(par7, par8);
1949            List var10 = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.contract(0.03125D, 0.0D, 0.03125D));
1950    
1951            if (!var10.isEmpty())
1952            {
1953                double var11 = 0.0D;
1954    
1955                for (int var13 = 0; var13 < var10.size(); ++var13)
1956                {
1957                    AxisAlignedBB var14 = (AxisAlignedBB)var10.get(var13);
1958    
1959                    if (var14.maxY > var11)
1960                    {
1961                        var11 = var14.maxY;
1962                    }
1963                }
1964    
1965                par3 += var11 - this.boundingBox.minY;
1966                this.setPosition(par1, par3, par5);
1967            }
1968        }
1969    
1970        public float getCollisionBorderSize()
1971        {
1972            return 0.1F;
1973        }
1974    
1975        /**
1976         * returns a (normalized) vector of where this entity is looking
1977         */
1978        public Vec3 getLookVec()
1979        {
1980            return null;
1981        }
1982    
1983        /**
1984         * Called by portal blocks when an entity is within it.
1985         */
1986        public void setInPortal()
1987        {
1988            if (this.timeUntilPortal > 0)
1989            {
1990                this.timeUntilPortal = this.getPortalCooldown();
1991            }
1992            else
1993            {
1994                double var1 = this.prevPosX - this.posX;
1995                double var3 = this.prevPosZ - this.posZ;
1996    
1997                if (!this.worldObj.isRemote && !this.inPortal)
1998                {
1999                    this.field_82152_aq = Direction.func_82372_a(var1, var3);
2000                }
2001    
2002                this.inPortal = true;
2003            }
2004        }
2005    
2006        /**
2007         * Return the amount of cooldown before this entity can use a portal again.
2008         */
2009        public int getPortalCooldown()
2010        {
2011            return 900;
2012        }
2013    
2014        @SideOnly(Side.CLIENT)
2015    
2016        /**
2017         * Sets the velocity to the args. Args: x, y, z
2018         */
2019        public void setVelocity(double par1, double par3, double par5)
2020        {
2021            this.motionX = par1;
2022            this.motionY = par3;
2023            this.motionZ = par5;
2024        }
2025    
2026        @SideOnly(Side.CLIENT)
2027        public void handleHealthUpdate(byte par1) {}
2028    
2029        @SideOnly(Side.CLIENT)
2030    
2031        /**
2032         * Setups the entity to do the hurt animation. Only used by packets in multiplayer.
2033         */
2034        public void performHurtAnimation() {}
2035    
2036        @SideOnly(Side.CLIENT)
2037        public void updateCloak() {}
2038    
2039        public ItemStack[] getLastActiveItems()
2040        {
2041            return null;
2042        }
2043    
2044        /**
2045         * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
2046         */
2047        public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) {}
2048    
2049        /**
2050         * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
2051         */
2052        public boolean isBurning()
2053        {
2054            return this.fire > 0 || this.getFlag(0);
2055        }
2056    
2057        /**
2058         * Returns true if the entity is riding another entity, used by render to rotate the legs to be in 'sit' position
2059         * for players.
2060         */
2061        public boolean isRiding()
2062        {
2063            return (this.ridingEntity != null && ridingEntity.shouldRiderSit()) || this.getFlag(2);
2064        }
2065    
2066        /**
2067         * Returns if this entity is sneaking.
2068         */
2069        public boolean isSneaking()
2070        {
2071            return this.getFlag(1);
2072        }
2073    
2074        /**
2075         * Sets the sneaking flag.
2076         */
2077        public void setSneaking(boolean par1)
2078        {
2079            this.setFlag(1, par1);
2080        }
2081    
2082        /**
2083         * Get if the Entity is sprinting.
2084         */
2085        public boolean isSprinting()
2086        {
2087            return this.getFlag(3);
2088        }
2089    
2090        /**
2091         * Set sprinting switch for Entity.
2092         */
2093        public void setSprinting(boolean par1)
2094        {
2095            this.setFlag(3, par1);
2096        }
2097    
2098        public boolean getHasActivePotion()
2099        {
2100            return this.getFlag(5);
2101        }
2102    
2103        public void setHasActivePotion(boolean par1)
2104        {
2105            this.setFlag(5, par1);
2106        }
2107    
2108        @SideOnly(Side.CLIENT)
2109        public boolean isEating()
2110        {
2111            return this.getFlag(4);
2112        }
2113    
2114        public void setEating(boolean par1)
2115        {
2116            this.setFlag(4, par1);
2117        }
2118    
2119        /**
2120         * Returns true if the flag is active for the entity. Known flags: 0) is burning; 1) is sneaking; 2) is riding
2121         * something; 3) is sprinting; 4) is eating
2122         */
2123        protected boolean getFlag(int par1)
2124        {
2125            return (this.dataWatcher.getWatchableObjectByte(0) & 1 << par1) != 0;
2126        }
2127    
2128        /**
2129         * Enable or disable a entity flag, see getEntityFlag to read the know flags.
2130         */
2131        protected void setFlag(int par1, boolean par2)
2132        {
2133            byte var3 = this.dataWatcher.getWatchableObjectByte(0);
2134    
2135            if (par2)
2136            {
2137                this.dataWatcher.updateObject(0, Byte.valueOf((byte)(var3 | 1 << par1)));
2138            }
2139            else
2140            {
2141                this.dataWatcher.updateObject(0, Byte.valueOf((byte)(var3 & ~(1 << par1))));
2142            }
2143        }
2144    
2145        public int getAir()
2146        {
2147            return this.dataWatcher.getWatchableObjectShort(1);
2148        }
2149    
2150        public void setAir(int par1)
2151        {
2152            this.dataWatcher.updateObject(1, Short.valueOf((short)par1));
2153        }
2154    
2155        /**
2156         * Called when a lightning bolt hits the entity.
2157         */
2158        public void onStruckByLightning(EntityLightningBolt par1EntityLightningBolt)
2159        {
2160            this.dealFireDamage(5);
2161            ++this.fire;
2162    
2163            if (this.fire == 0)
2164            {
2165                this.setFire(8);
2166            }
2167        }
2168    
2169        /**
2170         * This method gets called when the entity kills another one.
2171         */
2172        public void onKillEntity(EntityLiving par1EntityLiving) {}
2173    
2174        /**
2175         * Adds velocity to push the entity out of blocks at the specified x, y, z position Args: x, y, z
2176         */
2177        protected boolean pushOutOfBlocks(double par1, double par3, double par5)
2178        {
2179            int var7 = MathHelper.floor_double(par1);
2180            int var8 = MathHelper.floor_double(par3);
2181            int var9 = MathHelper.floor_double(par5);
2182            double var10 = par1 - (double)var7;
2183            double var12 = par3 - (double)var8;
2184            double var14 = par5 - (double)var9;
2185            List var16 = this.worldObj.getAllCollidingBoundingBoxes(this.boundingBox);
2186    
2187            if (var16.isEmpty() && !this.worldObj.func_85174_u(var7, var8, var9))
2188            {
2189                return false;
2190            }
2191            else
2192            {
2193                boolean var17 = !this.worldObj.func_85174_u(var7 - 1, var8, var9);
2194                boolean var18 = !this.worldObj.func_85174_u(var7 + 1, var8, var9);
2195                boolean var19 = !this.worldObj.func_85174_u(var7, var8 - 1, var9);
2196                boolean var20 = !this.worldObj.func_85174_u(var7, var8 + 1, var9);
2197                boolean var21 = !this.worldObj.func_85174_u(var7, var8, var9 - 1);
2198                boolean var22 = !this.worldObj.func_85174_u(var7, var8, var9 + 1);
2199                byte var23 = 3;
2200                double var24 = 9999.0D;
2201    
2202                if (var17 && var10 < var24)
2203                {
2204                    var24 = var10;
2205                    var23 = 0;
2206                }
2207    
2208                if (var18 && 1.0D - var10 < var24)
2209                {
2210                    var24 = 1.0D - var10;
2211                    var23 = 1;
2212                }
2213    
2214                if (var20 && 1.0D - var12 < var24)
2215                {
2216                    var24 = 1.0D - var12;
2217                    var23 = 3;
2218                }
2219    
2220                if (var21 && var14 < var24)
2221                {
2222                    var24 = var14;
2223                    var23 = 4;
2224                }
2225    
2226                if (var22 && 1.0D - var14 < var24)
2227                {
2228                    var24 = 1.0D - var14;
2229                    var23 = 5;
2230                }
2231    
2232                float var26 = this.rand.nextFloat() * 0.2F + 0.1F;
2233    
2234                if (var23 == 0)
2235                {
2236                    this.motionX = (double)(-var26);
2237                }
2238    
2239                if (var23 == 1)
2240                {
2241                    this.motionX = (double)var26;
2242                }
2243    
2244                if (var23 == 2)
2245                {
2246                    this.motionY = (double)(-var26);
2247                }
2248    
2249                if (var23 == 3)
2250                {
2251                    this.motionY = (double)var26;
2252                }
2253    
2254                if (var23 == 4)
2255                {
2256                    this.motionZ = (double)(-var26);
2257                }
2258    
2259                if (var23 == 5)
2260                {
2261                    this.motionZ = (double)var26;
2262                }
2263    
2264                return true;
2265            }
2266        }
2267    
2268        /**
2269         * Sets the Entity inside a web block.
2270         */
2271        public void setInWeb()
2272        {
2273            this.isInWeb = true;
2274            this.fallDistance = 0.0F;
2275        }
2276    
2277        /**
2278         * Gets the username of the entity.
2279         */
2280        public String getEntityName()
2281        {
2282            String var1 = EntityList.getEntityString(this);
2283    
2284            if (var1 == null)
2285            {
2286                var1 = "generic";
2287            }
2288    
2289            return StatCollector.translateToLocal("entity." + var1 + ".name");
2290        }
2291    
2292        /**
2293         * Return the Entity parts making up this Entity (currently only for dragons)
2294         */
2295        public Entity[] getParts()
2296        {
2297            return null;
2298        }
2299    
2300        /**
2301         * Returns true if Entity argument is equal to this Entity
2302         */
2303        public boolean isEntityEqual(Entity par1Entity)
2304        {
2305            return this == par1Entity;
2306        }
2307    
2308        public float setRotationYawHead()
2309        {
2310            return 0.0F;
2311        }
2312    
2313        @SideOnly(Side.CLIENT)
2314    
2315        /**
2316         * Sets the head's yaw rotation of the entity.
2317         */
2318        public void setHeadRotationYaw(float par1) {}
2319    
2320        /**
2321         * If returns false, the item will not inflict any damage against entities.
2322         */
2323        public boolean canAttackWithItem()
2324        {
2325            return true;
2326        }
2327    
2328        public boolean func_85031_j(Entity par1Entity)
2329        {
2330            return false;
2331        }
2332    
2333        public String toString()
2334        {
2335            return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] {this.getClass().getSimpleName(), this.getEntityName(), Integer.valueOf(this.entityId), this.worldObj == null ? "~NULL~" : this.worldObj.getWorldInfo().getWorldName(), Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)});
2336        }
2337    
2338        public boolean func_85032_ar()
2339        {
2340            return this.field_83001_bt;
2341        }
2342    
2343        public void func_82149_j(Entity par1Entity)
2344        {
2345            this.setLocationAndAngles(par1Entity.posX, par1Entity.posY, par1Entity.posZ, par1Entity.rotationYaw, par1Entity.rotationPitch);
2346        }
2347    
2348        /**
2349         * Copies important data from another entity to this entity. Used when teleporting entities between worlds, as this
2350         * actually deletes the teleporting entity and re-creates it on the other side. Params: Entity to copy from, unused
2351         * (always true)
2352         */
2353        public void copyDataFrom(Entity par1Entity, boolean par2)
2354        {
2355            NBTTagCompound var3 = new NBTTagCompound();
2356            par1Entity.writeToNBT(var3);
2357            this.readFromNBT(var3);
2358            this.timeUntilPortal = par1Entity.timeUntilPortal;
2359            this.field_82152_aq = par1Entity.field_82152_aq;
2360        }
2361    
2362        /**
2363         * Teleports the entity to another dimension. Params: Dimension number to teleport to
2364         */
2365        public void travelToDimension(int par1)
2366        {
2367            if (!this.worldObj.isRemote && !this.isDead)
2368            {
2369                this.worldObj.theProfiler.startSection("changeDimension");
2370                MinecraftServer var2 = MinecraftServer.getServer();
2371                int var3 = this.dimension;
2372                WorldServer var4 = var2.worldServerForDimension(var3);
2373                WorldServer var5 = var2.worldServerForDimension(par1);
2374                this.dimension = par1;
2375                this.worldObj.setEntityDead(this);
2376                this.isDead = false;
2377                this.worldObj.theProfiler.startSection("reposition");
2378                var2.getConfigurationManager().transferEntityToWorld(this, var3, var4, var5);
2379                this.worldObj.theProfiler.endStartSection("reloading");
2380                Entity var6 = EntityList.createEntityByName(EntityList.getEntityString(this), var5);
2381    
2382                if (var6 != null)
2383                {
2384                    var6.copyDataFrom(this, true);
2385                    var5.spawnEntityInWorld(var6);
2386                }
2387    
2388                this.isDead = true;
2389                this.worldObj.theProfiler.endSection();
2390                var4.resetUpdateEntityTick();
2391                var5.resetUpdateEntityTick();
2392                this.worldObj.theProfiler.endSection();
2393            }
2394        }
2395    
2396        public float func_82146_a(Explosion par1Explosion, Block par2Block, int par3, int par4, int par5)
2397        {
2398            return par2Block.getExplosionResistance(this, worldObj, par3, par4, par5, posX, posY + (double)getEyeHeight(), posZ);
2399        }
2400    
2401        public int func_82143_as()
2402        {
2403            return 3;
2404        }
2405    
2406        public int func_82148_at()
2407        {
2408            return this.field_82152_aq;
2409        }
2410    
2411        /**
2412         * Return whether this entity should NOT trigger a pressure plate or a tripwire.
2413         */
2414        public boolean doesEntityNotTriggerPressurePlate()
2415        {
2416            return false;
2417        }
2418    
2419        public void func_85029_a(CrashReportCategory par1CrashReportCategory)
2420        {
2421            par1CrashReportCategory.addCrashSectionCallable("Entity Type", new CallableEntityType(this));
2422            par1CrashReportCategory.addCrashSection("Entity ID", Integer.valueOf(this.entityId));
2423            par1CrashReportCategory.addCrashSection("Name", this.getEntityName());
2424            par1CrashReportCategory.addCrashSection("Exact location", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)}));
2425            par1CrashReportCategory.addCrashSection("Block location", CrashReportCategory.func_85071_a(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)));
2426            par1CrashReportCategory.addCrashSection("Momentum", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ)}));
2427        }
2428    
2429        @SideOnly(Side.CLIENT)
2430    
2431        /**
2432         * Return whether this entity should be rendered as on fire.
2433         */
2434        public boolean canRenderOnFire()
2435        {
2436            return this.isBurning();
2437        }
2438    
2439        /* ================================== Forge Start =====================================*/
2440        /**
2441         * Returns a NBTTagCompound that can be used to store custom data for this entity.
2442         * It will be written, and read from disc, so it persists over world saves.
2443         * @return A NBTTagCompound
2444         */
2445        public NBTTagCompound getEntityData()
2446        {
2447            if (customEntityData == null)
2448            {
2449                customEntityData = new NBTTagCompound();
2450            }
2451            return customEntityData;
2452        }
2453    
2454        /**
2455         * Used in model rendering to determine if the entity riding this entity should be in the 'sitting' position.
2456         * @return false to prevent an entity that is mounted to this entity from displaying the 'sitting' animation.
2457         */
2458        public boolean shouldRiderSit()
2459        {
2460            return true;
2461        }
2462    
2463        /**
2464         * Called when a user uses the creative pick block button on this entity.
2465         *
2466         * @param target The full target the player is looking at
2467         * @return A ItemStack to add to the player's inventory, Null if nothing should be added.
2468         */
2469        public ItemStack getPickedResult(MovingObjectPosition target)
2470        {
2471            if (this instanceof EntityPainting)
2472            {
2473                return new ItemStack(Item.painting);
2474            }
2475            else if (this instanceof EntityMinecart)
2476            {
2477                return ((EntityMinecart)this).getCartItem();
2478            }
2479            else if (this instanceof EntityBoat)
2480            {
2481                return new ItemStack(Item.boat);
2482            }
2483            else if (this instanceof EntityItemFrame)
2484            {
2485                ItemStack held = ((EntityItemFrame)this).getDisplayedItem();
2486                if (held == null)
2487                {
2488                    return new ItemStack(Item.itemFrame);
2489                }
2490                else
2491                {
2492                    return held.copy();
2493                }
2494            }
2495            else
2496            {
2497                int id = EntityList.getEntityID(this);
2498                if (id > 0 && EntityList.entityEggs.containsKey(id))
2499                {
2500                    return new ItemStack(Item.monsterPlacer, 1, id);
2501                }
2502            }
2503            return null;
2504        }
2505    
2506        public UUID getPersistentID()
2507        {
2508            return persistentID;
2509        }
2510    
2511        public synchronized void generatePersistentID()
2512        {
2513            if (persistentID == null)
2514            {
2515                persistentID = UUID.randomUUID();
2516            }
2517        }
2518    }