Entity .java

net.minecraft.entity.Entity (class, 2820 lines): members: distanceWalkedOnStepModified, prevDistanceWalkedModified, copyLocationAndAnglesFrom, getAir.

net.minecraft.entityclass2,820 linescommon86.2 KB

Implements

API Surface (179)

int getEntityId()
void setEntityId(int id)
void onKillCommand()
DataWatcher getDataWatcher()
boolean equals(Object p_equals_1_)
int hashCode()
void preparePlayerToSpawn()
void setDead()
void setSize(float width, float height)
void setRotation(float yaw, float pitch)
void setPosition(double x, double y, double z)
void setAngles(float yaw, float pitch)
void onUpdate()
void onEntityUpdate()
int getMaxInPortalTime()
void setOnFireFromLava()
void setFire(int seconds)
void extinguish()
void kill()
boolean isOffsetPositionInLiquid(double x, double y, double z)
void moveEntity(double x, double y, double z)
String getSwimSound()
void doBlockCollisions()
void playStepSound(BlockPos pos, Block blockIn)
void playSound(String name, float volume, float pitch)
boolean isSilent()
void setSilent(boolean isSilent)
boolean canTriggerWalking()
void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
AxisAlignedBB getCollisionBoundingBox()
void dealFireDamage(int amount)
boolean isImmuneToFire()
void fall(float distance, float damageMultiplier)
boolean isWet()
boolean isInWater()
boolean handleWaterMovement()
void resetHeight()
void spawnRunningParticles()
void createRunningParticles()
String getSplashSound()
boolean isInsideOfMaterial(Material materialIn)
boolean isInLava()
void moveFlying(float strafe, float forward, float friction)
int getBrightnessForRender(float partialTicks)
float getBrightness(float partialTicks)
void setWorld(World worldIn)
void setPositionAndRotation(double x, double y, double z, float yaw, float pitch)
void moveToBlockPosAndAngles(BlockPos pos, float rotationYawIn, float rotationPitchIn)
void setLocationAndAngles(double x, double y, double z, float yaw, float pitch)
float getDistanceToEntity(Entity entityIn)
double getDistanceSq(double x, double y, double z)
double getDistanceSq(BlockPos pos)
double getDistanceSqToCenter(BlockPos pos)
double getDistance(double x, double y, double z)
double getDistanceSqToEntity(Entity entityIn)
void onCollideWithPlayer(EntityPlayer entityIn)
void applyEntityCollision(Entity entityIn)
void addVelocity(double x, double y, double z)
void setBeenAttacked()
boolean attackEntityFrom(DamageSource source, float amount)
Vec3 getLook(float partialTicks)
Vec3 getVectorForRotation(float pitch, float yaw)
Vec3 getPositionEyes(float partialTicks)
MovingObjectPosition rayTrace(double blockReachDistance, float partialTicks)
boolean canBeCollidedWith()
boolean canBePushed()
void addToPlayerScore(Entity entityIn, int amount)
boolean isInRangeToRender3d(double x, double y, double z)
boolean isInRangeToRenderDist(double distance)
boolean writeMountToNBT(NBTTagCompound tagCompund)
boolean writeToNBTOptional(NBTTagCompound tagCompund)
void writeToNBT(NBTTagCompound tagCompund)
void readFromNBT(NBTTagCompound tagCompund)
boolean shouldSetPosAfterLoading()
String getEntityString()
void onChunkLoad()
NBTTagList newDoubleNBTList(double... numbers)
NBTTagList newFloatNBTList(float... numbers)
EntityItem dropItem(Item itemIn, int size)
EntityItem dropItemWithOffset(Item itemIn, int size, float offsetY)
EntityItem entityDropItem(ItemStack itemStackIn, float offsetY)
boolean isEntityAlive()
boolean isEntityInsideOpaqueBlock()
boolean interactFirst(EntityPlayer playerIn)
AxisAlignedBB getCollisionBox(Entity entityIn)
void updateRidden()
void updateRiderPosition()
double getYOffset()
double getMountedYOffset()
void mountEntity(Entity entityIn)
void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
float getCollisionBorderSize()
Vec3 getLookVec()
void setPortal(BlockPos pos)
int getPortalCooldown()
void setVelocity(double x, double y, double z)
void handleStatusUpdate(byte id)
void performHurtAnimation()
ItemStack[] getInventory()
void setCurrentItemOrArmor(int slotIn, ItemStack stack)
boolean isBurning()
boolean isRiding()
boolean isSneaking()
void setSneaking(boolean sneaking)
boolean isSprinting()
void setSprinting(boolean sprinting)
boolean isInvisible()
boolean isInvisibleToPlayer(EntityPlayer player)
void setInvisible(boolean invisible)
boolean isEating()
void setEating(boolean eating)
boolean getFlag(int flag)
void setFlag(int flag, boolean set)
int getAir()
void setAir(int air)
void onStruckByLightning(EntityLightningBolt lightningBolt)
void onKillEntity(EntityLivingBase entityLivingIn)
boolean pushOutOfBlocks(double x, double y, double z)
void setInWeb()
String getName()

…and 59 more (see full source).

Fields & Constants (74)

ZERO_AABB
nextEntityID
entityId
renderDistanceWeight
preventEntitySpawning
riddenByEntity
ridingEntity
forceSpawn
worldObj
prevPosX
prevPosY
prevPosZ
posX
posY
posZ
motionX
motionY
motionZ
rotationYaw
rotationPitch
prevRotationYaw
prevRotationPitch
boundingBox
onGround
isCollidedHorizontally

…and 49 more (see full source).

String literals (45)

"entityBaseTick"
"portal"
"move"
"rest"
"Checking entity block collision"
"Entity being checked for collision"
"random.fizz"
"game.neutral.swim"
"Colliding entity with block"
"Block being collided with"
"game.neutral.swim.splash"
"Motion"
"Rotation"
"FallDistance"
"Fire"
"OnGround"
"Dimension"
"Invulnerable"
"PortalCooldown"
"UUIDMost"
"UUIDLeast"
"CustomName"
"CustomNameVisible"
"Silent"

Full Source

Entity.java2820 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity;
2
3
import java.util.List;
4
import java.util.Random;
5
import java.util.UUID;
6
import java.util.concurrent.Callable;
7
import net.minecraft.block.Block;
8
import net.minecraft.block.BlockFence;
9
import net.minecraft.block.BlockFenceGate;
10
import net.minecraft.block.BlockLiquid;
11
import net.minecraft.block.BlockWall;
12
import net.minecraft.block.material.Material;
13
import net.minecraft.block.state.IBlockState;
14
import net.minecraft.block.state.pattern.BlockPattern;
15
import net.minecraft.command.CommandResultStats;
16
import net.minecraft.command.ICommandSender;
17
import net.minecraft.crash.CrashReport;
18
import net.minecraft.crash.CrashReportCategory;
19
import net.minecraft.enchantment.EnchantmentHelper;
20
import net.minecraft.enchantment.EnchantmentProtection;
21
import net.minecraft.entity.effect.EntityLightningBolt;
22
import net.minecraft.entity.item.EntityItem;
23
import net.minecraft.entity.player.EntityPlayer;
24
import net.minecraft.entity.player.EntityPlayerMP;
25
import net.minecraft.event.HoverEvent;
26
import net.minecraft.init.Blocks;
27
import net.minecraft.item.Item;
28
import net.minecraft.item.ItemStack;
29
import net.minecraft.nbt.NBTTagCompound;
30
import net.minecraft.nbt.NBTTagDouble;
31
import net.minecraft.nbt.NBTTagFloat;
32
import net.minecraft.nbt.NBTTagList;
33
import net.minecraft.server.MinecraftServer;
34
import net.minecraft.util.AxisAlignedBB;
35
import net.minecraft.util.BlockPos;
36
import net.minecraft.util.ChatComponentText;
37
import net.minecraft.util.DamageSource;
38
import net.minecraft.util.EnumFacing;
39
import net.minecraft.util.EnumParticleTypes;
40
import net.minecraft.util.IChatComponent;
41
import net.minecraft.util.MathHelper;
42
import net.minecraft.util.MovingObjectPosition;
43
import net.minecraft.util.ReportedException;
44
import net.minecraft.util.StatCollector;
45
import net.minecraft.util.Vec3;
46
import net.minecraft.world.Explosion;
47
import net.minecraft.world.World;
48
import net.minecraft.world.WorldServer;
49
50
public abstract class Entity implements ICommandSender
51
{
52
    private static final AxisAlignedBB ZERO_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
53
    private static int nextEntityID;
54
    private int entityId;
55
    public double renderDistanceWeight;
56
57
    /**
58
     * Blocks entities from spawning when they do their AABB check to make sure the spot is clear of entities that can
59
     * prevent spawning.
60
     */
61
    public boolean preventEntitySpawning;
62
63
    /** The entity that is riding this entity */
64
    public Entity riddenByEntity;
65
66
    /** The entity we are currently riding */
67
    public Entity ridingEntity;
68
    public boolean forceSpawn;
69
70
    /** Reference to the World object. */
71
    public World worldObj;
72
    public double prevPosX;
73
    public double prevPosY;
74
    public double prevPosZ;
75
76
    /** Entity position X */
77
    public double posX;
78
79
    /** Entity position Y */
80
    public double posY;
81
82
    /** Entity position Z */
83
    public double posZ;
84
85
    /** Entity motion X */
86
    public double motionX;
87
88
    /** Entity motion Y */
89
    public double motionY;
90
91
    /** Entity motion Z */
92
    public double motionZ;
93
94
    /** Entity rotation Yaw */
95
    public float rotationYaw;
96
97
    /** Entity rotation Pitch */
98
    public float rotationPitch;
99
    public float prevRotationYaw;
100
    public float prevRotationPitch;
101
102
    /** Axis aligned bounding box. */
103
    private AxisAlignedBB boundingBox;
104
    public boolean onGround;
105
106
    /**
107
     * True if after a move this entity has collided with something on X- or Z-axis
108
     */
109
    public boolean isCollidedHorizontally;
110
111
    /**
112
     * True if after a move this entity has collided with something on Y-axis
113
     */
114
    public boolean isCollidedVertically;
115
116
    /**
117
     * True if after a move this entity has collided with something either vertically or horizontally
118
     */
119
    public boolean isCollided;
120
    public boolean velocityChanged;
121
    protected boolean isInWeb;
122
    private boolean isOutsideBorder;
123
124
    /**
125
     * gets set by setEntityDead, so this must be the flag whether an Entity is dead (inactive may be better term)
126
     */
127
    public boolean isDead;
128
129
    /** How wide this entity is considered to be */
130
    public float width;
131
132
    /** How high this entity is considered to be */
133
    public float height;
134
135
    /** The previous ticks distance walked multiplied by 0.6 */
136
    public float prevDistanceWalkedModified;
137
138
    /** The distance walked multiplied by 0.6 */
139
    public float distanceWalkedModified;
140
    public float distanceWalkedOnStepModified;
141
    public float fallDistance;
142
143
    /**
144
     * The distance that has to be exceeded in order to triger a new step sound and an onEntityWalking event on a block
145
     */
146
    private int nextStepDistance;
147
148
    /**
149
     * The entity's X coordinate at the previous tick, used to calculate position during rendering routines
150
     */
151
    public double lastTickPosX;
152
153
    /**
154
     * The entity's Y coordinate at the previous tick, used to calculate position during rendering routines
155
     */
156
    public double lastTickPosY;
157
158
    /**
159
     * The entity's Z coordinate at the previous tick, used to calculate position during rendering routines
160
     */
161
    public double lastTickPosZ;
162
163
    /**
164
     * How high this entity can step up when running into a block to try to get over it (currently make note the entity
165
     * will always step up this amount and not just the amount needed)
166
     */
167
    public float stepHeight;
168
169
    /**
170
     * Whether this entity won't clip with collision or not (make note it won't disable gravity)
171
     */
172
    public boolean noClip;
173
174
    /**
175
     * Reduces the velocity applied by entity collisions by the specified percent.
176
     */
177
    public float entityCollisionReduction;
178
    protected Random rand;
179
180
    /** How many ticks has this entity had ran since being alive */
181
    public int ticksExisted;
182
183
    /**
184
     * The amount of ticks you have to stand inside of fire before be set on fire
185
     */
186
    public int fireResistance;
187
    private int fire;
188
189
    /**
190
     * Whether this entity is currently inside of water (if it handles water movement that is)
191
     */
192
    protected boolean inWater;
193
194
    /**
195
     * Remaining time an entity will be "immune" to further damage after being hurt.
196
     */
197
    public int hurtResistantTime;
198
    protected boolean firstUpdate;
199
    protected boolean isImmuneToFire;
200
    protected DataWatcher dataWatcher;
201
    private double entityRiderPitchDelta;
202
    private double entityRiderYawDelta;
203
204
    /** Has this entity been added to the chunk its within */
205
    public boolean addedToChunk;
206
    public int chunkCoordX;
207
    public int chunkCoordY;
208
    public int chunkCoordZ;
209
    public int serverPosX;
210
    public int serverPosY;
211
    public int serverPosZ;
212
213
    /**
214
     * Render entity even if it is outside the camera frustum. Only true in EntityFish for now. Used in RenderGlobal:
215
     * render if ignoreFrustumCheck or in frustum.
216
     */
217
    public boolean ignoreFrustumCheck;
218
    public boolean isAirBorne;
219
    public int timeUntilPortal;
220
221
    /** Whether the entity is inside a Portal */
222
    protected boolean inPortal;
223
    protected int portalCounter;
224
225
    /** Which dimension the player is in (-1 = the Nether, 0 = normal world) */
226
    public int dimension;
227
228
    /** The position of the last portal the entity was in */
229
    protected BlockPos lastPortalPos;
230
231
    /**
232
     * A horizontal vector related to the position of the last portal the entity was in
233
     */
234
    protected Vec3 lastPortalVec;
235
236
    /**
237
     * A direction related to the position of the last portal the entity was in
238
     */
239
    protected EnumFacing teleportDirection;
240
    private boolean invulnerable;
241
    protected UUID entityUniqueID;
242
243
    /** The command result statistics for this Entity. */
244
    private final CommandResultStats cmdResultStats;
245
246
    public int getEntityId()
247
    {
248
        return this.entityId;
249
    }
250
251
    public void setEntityId(int id)
252
    {
253
        this.entityId = id;
254
    }
255
256
    /**
257
     * Called by the /kill command.
258
     */
259
    public void onKillCommand()
260
    {
261
        this.setDead();
262
    }
263
264
    public Entity(World worldIn)
265
    {
266
        this.entityId = nextEntityID++;
267
        this.renderDistanceWeight = 1.0D;
268
        this.boundingBox = ZERO_AABB;
269
        this.width = 0.6F;
270
        this.height = 1.8F;
271
        this.nextStepDistance = 1;
272
        this.rand = new Random();
273
        this.fireResistance = 1;
274
        this.firstUpdate = true;
275
        this.entityUniqueID = MathHelper.getRandomUuid(this.rand);
276
        this.cmdResultStats = new CommandResultStats();
277
        this.worldObj = worldIn;
278
        this.setPosition(0.0D, 0.0D, 0.0D);
279
280
        if (worldIn != null)
281
        {
282
            this.dimension = worldIn.provider.getDimensionId();
283
        }
284
285
        this.dataWatcher = new DataWatcher(this);
286
        this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
287
        this.dataWatcher.addObject(1, Short.valueOf((short)300));
288
        this.dataWatcher.addObject(3, Byte.valueOf((byte)0));
289
        this.dataWatcher.addObject(2, "");
290
        this.dataWatcher.addObject(4, Byte.valueOf((byte)0));
291
        this.entityInit();
292
    }
293
294
    protected abstract void entityInit();
295
296
    public DataWatcher getDataWatcher()
297
    {
298
        return this.dataWatcher;
299
    }
300
301
    public boolean equals(Object p_equals_1_)
302
    {
303
        return p_equals_1_ instanceof Entity ? ((Entity)p_equals_1_).entityId == this.entityId : false;
304
    }
305
306
    public int hashCode()
307
    {
308
        return this.entityId;
309
    }
310
311
    /**
312
     * Keeps moving the entity up so it isn't colliding with blocks and other requirements for this entity to be spawned
313
     * (only actually used on players though its also on Entity)
314
     */
315
    protected void preparePlayerToSpawn()
316
    {
317
        if (this.worldObj != null)
318
        {
319
            while (this.posY > 0.0D && this.posY < 256.0D)
320
            {
321
                this.setPosition(this.posX, this.posY, this.posZ);
322
323
                if (this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty())
324
                {
325
                    break;
326
                }
327
328
                ++this.posY;
329
            }
330
331
            this.motionX = this.motionY = this.motionZ = 0.0D;
332
            this.rotationPitch = 0.0F;
333
        }
334
    }
335
336
    /**
337
     * Will get destroyed next tick.
338
     */
339
    public void setDead()
340
    {
341
        this.isDead = true;
342
    }
343
344
    /**
345
     * Sets the width and height of the entity. Args: width, height
346
     */
347
    protected void setSize(float width, float height)
348
    {
349
        if (width != this.width || height != this.height)
350
        {
351
            float f = this.width;
352
            this.width = width;
353
            this.height = height;
354
            this.setEntityBoundingBox(new AxisAlignedBB(this.getEntityBoundingBox().minX, this.getEntityBoundingBox().minY, this.getEntityBoundingBox().minZ, this.getEntityBoundingBox().minX + (double)this.width, this.getEntityBoundingBox().minY + (double)this.height, this.getEntityBoundingBox().minZ + (double)this.width));
355
356
            if (this.width > f && !this.firstUpdate && !this.worldObj.isRemote)
357
            {
358
                this.moveEntity((double)(f - this.width), 0.0D, (double)(f - this.width));
359
            }
360
        }
361
    }
362
363
    /**
364
     * Sets the rotation of the entity. Args: yaw, pitch (both in degrees)
365
     */
366
    protected void setRotation(float yaw, float pitch)
367
    {
368
        this.rotationYaw = yaw % 360.0F;
369
        this.rotationPitch = pitch % 360.0F;
370
    }
371
372
    /**
373
     * Sets the x,y,z of the entity from the given parameters. Also seems to set up a bounding box.
374
     */
375
    public void setPosition(double x, double y, double z)
376
    {
377
        this.posX = x;
378
        this.posY = y;
379
        this.posZ = z;
380
        float f = this.width / 2.0F;
381
        float f1 = this.height;
382
        this.setEntityBoundingBox(new AxisAlignedBB(x - (double)f, y, z - (double)f, x + (double)f, y + (double)f1, z + (double)f));
383
    }
384
385
    /**
386
     * Adds 15% to the entity's yaw and subtracts 15% from the pitch. Clamps pitch from -90 to 90. Both arguments in
387
     * degrees.
388
     */
389
    public void setAngles(float yaw, float pitch)
390
    {
391
        float f = this.rotationPitch;
392
        float f1 = this.rotationYaw;
393
        this.rotationYaw = (float)((double)this.rotationYaw + (double)yaw * 0.15D);
394
        this.rotationPitch = (float)((double)this.rotationPitch - (double)pitch * 0.15D);
395
        this.rotationPitch = MathHelper.clamp_float(this.rotationPitch, -90.0F, 90.0F);
396
        this.prevRotationPitch += this.rotationPitch - f;
397
        this.prevRotationYaw += this.rotationYaw - f1;
398
    }
399
400
    /**
401
     * Called to update the entity's position/logic.
402
     */
403
    public void onUpdate()
404
    {
405
        this.onEntityUpdate();
406
    }
407
408
    /**
409
     * Gets called every tick from main Entity class
410
     */
411
    public void onEntityUpdate()
412
    {
413
        this.worldObj.theProfiler.startSection("entityBaseTick");
414
415
        if (this.ridingEntity != null && this.ridingEntity.isDead)
416
        {
417
            this.ridingEntity = null;
418
        }
419
420
        this.prevDistanceWalkedModified = this.distanceWalkedModified;
421
        this.prevPosX = this.posX;
422
        this.prevPosY = this.posY;
423
        this.prevPosZ = this.posZ;
424
        this.prevRotationPitch = this.rotationPitch;
425
        this.prevRotationYaw = this.rotationYaw;
426
427
        if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer)
428
        {
429
            this.worldObj.theProfiler.startSection("portal");
430
            MinecraftServer minecraftserver = ((WorldServer)this.worldObj).getMinecraftServer();
431
            int i = this.getMaxInPortalTime();
432
433
            if (this.inPortal)
434
            {
435
                if (minecraftserver.getAllowNether())
436
                {
437
                    if (this.ridingEntity == null && this.portalCounter++ >= i)
438
                    {
439
                        this.portalCounter = i;
440
                        this.timeUntilPortal = this.getPortalCooldown();
441
                        int j;
442
443
                        if (this.worldObj.provider.getDimensionId() == -1)
444
                        {
445
                            j = 0;
446
                        }
447
                        else
448
                        {
449
                            j = -1;
450
                        }
451
452
                        this.travelToDimension(j);
453
                    }
454
455
                    this.inPortal = false;
456
                }
457
            }
458
            else
459
            {
460
                if (this.portalCounter > 0)
461
                {
462
                    this.portalCounter -= 4;
463
                }
464
465
                if (this.portalCounter < 0)
466
                {
467
                    this.portalCounter = 0;
468
                }
469
            }
470
471
            if (this.timeUntilPortal > 0)
472
            {
473
                --this.timeUntilPortal;
474
            }
475
476
            this.worldObj.theProfiler.endSection();
477
        }
478
479
        this.spawnRunningParticles();
480
        this.handleWaterMovement();
481
482
        if (this.worldObj.isRemote)
483
        {
484
            this.fire = 0;
485
        }
486
        else if (this.fire > 0)
487
        {
488
            if (this.isImmuneToFire)
489
            {
490
                this.fire -= 4;
491
492
                if (this.fire < 0)
493
                {
494
                    this.fire = 0;
495
                }
496
            }
497
            else
498
            {
499
                if (this.fire % 20 == 0)
500
                {
501
                    this.attackEntityFrom(DamageSource.onFire, 1.0F);
502
                }
503
504
                --this.fire;
505
            }
506
        }
507
508
        if (this.isInLava())
509
        {
510
            this.setOnFireFromLava();
511
            this.fallDistance *= 0.5F;
512
        }
513
514
        if (this.posY < -64.0D)
515
        {
516
            this.kill();
517
        }
518
519
        if (!this.worldObj.isRemote)
520
        {
521
            this.setFlag(0, this.fire > 0);
522
        }
523
524
        this.firstUpdate = false;
525
        this.worldObj.theProfiler.endSection();
526
    }
527
528
    /**
529
     * Return the amount of time this entity should stay in a portal before being transported.
530
     */
531
    public int getMaxInPortalTime()
532
    {
533
        return 0;
534
    }
535
536
    /**
537
     * Called whenever the entity is walking inside of lava.
538
     */
539
    protected void setOnFireFromLava()
540
    {
541
        if (!this.isImmuneToFire)
542
        {
543
            this.attackEntityFrom(DamageSource.lava, 4.0F);
544
            this.setFire(15);
545
        }
546
    }
547
548
    /**
549
     * Sets entity to burn for x amount of seconds, cannot lower amount of existing fire.
550
     */
551
    public void setFire(int seconds)
552
    {
553
        int i = seconds * 20;
554
        i = EnchantmentProtection.getFireTimeForEntity(this, i);
555
556
        if (this.fire < i)
557
        {
558
            this.fire = i;
559
        }
560
    }
561
562
    /**
563
     * Removes fire from entity.
564
     */
565
    public void extinguish()
566
    {
567
        this.fire = 0;
568
    }
569
570
    /**
571
     * sets the dead flag. Used when you fall off the bottom of the world.
572
     */
573
    protected void kill()
574
    {
575
        this.setDead();
576
    }
577
578
    /**
579
     * Checks if the offset position from the entity's current position is inside of liquid. Args: x, y, z
580
     */
581
    public boolean isOffsetPositionInLiquid(double x, double y, double z)
582
    {
583
        AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().offset(x, y, z);
584
        return this.isLiquidPresentInAABB(axisalignedbb);
585
    }
586
587
    /**
588
     * Determines if a liquid is present within the specified AxisAlignedBB.
589
     */
590
    private boolean isLiquidPresentInAABB(AxisAlignedBB bb)
591
    {
592
        return this.worldObj.getCollidingBoundingBoxes(this, bb).isEmpty() && !this.worldObj.isAnyLiquid(bb);
593
    }
594
595
    /**
596
     * Tries to moves the entity by the passed in displacement. Args: x, y, z
597
     */
598
    public void moveEntity(double x, double y, double z)
599
    {
600
        if (this.noClip)
601
        {
602
            this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
603
            this.resetPositionToBB();
604
        }
605
        else
606
        {
607
            this.worldObj.theProfiler.startSection("move");
608
            double d0 = this.posX;
609
            double d1 = this.posY;
610
            double d2 = this.posZ;
611
612
            if (this.isInWeb)
613
            {
614
                this.isInWeb = false;
615
                x *= 0.25D;
616
                y *= 0.05000000074505806D;
617
                z *= 0.25D;
618
                this.motionX = 0.0D;
619
                this.motionY = 0.0D;
620
                this.motionZ = 0.0D;
621
            }
622
623
            double d3 = x;
624
            double d4 = y;
625
            double d5 = z;
626
            boolean flag = this.onGround && this.isSneaking() && this instanceof EntityPlayer;
627
628
            if (flag)
629
            {
630
                double d6;
631
632
                for (d6 = 0.05D; x != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox().offset(x, -1.0D, 0.0D)).isEmpty(); d3 = x)
633
                {
634
                    if (x < d6 && x >= -d6)
635
                    {
636
                        x = 0.0D;
637
                    }
638
                    else if (x > 0.0D)
639
                    {
640
                        x -= d6;
641
                    }
642
                    else
643
                    {
644
                        x += d6;
645
                    }
646
                }
647
648
                for (; z != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox().offset(0.0D, -1.0D, z)).isEmpty(); d5 = z)
649
                {
650
                    if (z < d6 && z >= -d6)
651
                    {
652
                        z = 0.0D;
653
                    }
654
                    else if (z > 0.0D)
655
                    {
656
                        z -= d6;
657
                    }
658
                    else
659
                    {
660
                        z += d6;
661
                    }
662
                }
663
664
                for (; x != 0.0D && z != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox().offset(x, -1.0D, z)).isEmpty(); d5 = z)
665
                {
666
                    if (x < d6 && x >= -d6)
667
                    {
668
                        x = 0.0D;
669
                    }
670
                    else if (x > 0.0D)
671
                    {
672
                        x -= d6;
673
                    }
674
                    else
675
                    {
676
                        x += d6;
677
                    }
678
679
                    d3 = x;
680
681
                    if (z < d6 && z >= -d6)
682
                    {
683
                        z = 0.0D;
684
                    }
685
                    else if (z > 0.0D)
686
                    {
687
                        z -= d6;
688
                    }
689
                    else
690
                    {
691
                        z += d6;
692
                    }
693
                }
694
            }
695
696
            List<AxisAlignedBB> list1 = this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox().addCoord(x, y, z));
697
            AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
698
699
            for (AxisAlignedBB axisalignedbb1 : list1)
700
            {
701
                y = axisalignedbb1.calculateYOffset(this.getEntityBoundingBox(), y);
702
            }
703
704
            this.setEntityBoundingBox(this.getEntityBoundingBox().offset(0.0D, y, 0.0D));
705
            boolean flag1 = this.onGround || d4 != y && d4 < 0.0D;
706
707
            for (AxisAlignedBB axisalignedbb2 : list1)
708
            {
709
                x = axisalignedbb2.calculateXOffset(this.getEntityBoundingBox(), x);
710
            }
711
712
            this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, 0.0D, 0.0D));
713
714
            for (AxisAlignedBB axisalignedbb13 : list1)
715
            {
716
                z = axisalignedbb13.calculateZOffset(this.getEntityBoundingBox(), z);
717
            }
718
719
            this.setEntityBoundingBox(this.getEntityBoundingBox().offset(0.0D, 0.0D, z));
720
721
            if (this.stepHeight > 0.0F && flag1 && (d3 != x || d5 != z))
722
            {
723
                double d11 = x;
724
                double d7 = y;
725
                double d8 = z;
726
                AxisAlignedBB axisalignedbb3 = this.getEntityBoundingBox();
727
                this.setEntityBoundingBox(axisalignedbb);
728
                y = (double)this.stepHeight;
729
                List<AxisAlignedBB> list = this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox().addCoord(d3, y, d5));
730
                AxisAlignedBB axisalignedbb4 = this.getEntityBoundingBox();
731
                AxisAlignedBB axisalignedbb5 = axisalignedbb4.addCoord(d3, 0.0D, d5);
732
                double d9 = y;
733
734
                for (AxisAlignedBB axisalignedbb6 : list)
735
                {
736
                    d9 = axisalignedbb6.calculateYOffset(axisalignedbb5, d9);
737
                }
738
739
                axisalignedbb4 = axisalignedbb4.offset(0.0D, d9, 0.0D);
740
                double d15 = d3;
741
742
                for (AxisAlignedBB axisalignedbb7 : list)
743
                {
744
                    d15 = axisalignedbb7.calculateXOffset(axisalignedbb4, d15);
745
                }
746
747
                axisalignedbb4 = axisalignedbb4.offset(d15, 0.0D, 0.0D);
748
                double d16 = d5;
749
750
                for (AxisAlignedBB axisalignedbb8 : list)
751
                {
752
                    d16 = axisalignedbb8.calculateZOffset(axisalignedbb4, d16);
753
                }
754
755
                axisalignedbb4 = axisalignedbb4.offset(0.0D, 0.0D, d16);
756
                AxisAlignedBB axisalignedbb14 = this.getEntityBoundingBox();
757
                double d17 = y;
758
759
                for (AxisAlignedBB axisalignedbb9 : list)
760
                {
761
                    d17 = axisalignedbb9.calculateYOffset(axisalignedbb14, d17);
762
                }
763
764
                axisalignedbb14 = axisalignedbb14.offset(0.0D, d17, 0.0D);
765
                double d18 = d3;
766
767
                for (AxisAlignedBB axisalignedbb10 : list)
768
                {
769
                    d18 = axisalignedbb10.calculateXOffset(axisalignedbb14, d18);
770
                }
771
772
                axisalignedbb14 = axisalignedbb14.offset(d18, 0.0D, 0.0D);
773
                double d19 = d5;
774
775
                for (AxisAlignedBB axisalignedbb11 : list)
776
                {
777
                    d19 = axisalignedbb11.calculateZOffset(axisalignedbb14, d19);
778
                }
779
780
                axisalignedbb14 = axisalignedbb14.offset(0.0D, 0.0D, d19);
781
                double d20 = d15 * d15 + d16 * d16;
782
                double d10 = d18 * d18 + d19 * d19;
783
784
                if (d20 > d10)
785
                {
786
                    x = d15;
787
                    z = d16;
788
                    y = -d9;
789
                    this.setEntityBoundingBox(axisalignedbb4);
790
                }
791
                else
792
                {
793
                    x = d18;
794
                    z = d19;
795
                    y = -d17;
796
                    this.setEntityBoundingBox(axisalignedbb14);
797
                }
798
799
                for (AxisAlignedBB axisalignedbb12 : list)
800
                {
801
                    y = axisalignedbb12.calculateYOffset(this.getEntityBoundingBox(), y);
802
                }
803
804
                this.setEntityBoundingBox(this.getEntityBoundingBox().offset(0.0D, y, 0.0D));
805
806
                if (d11 * d11 + d8 * d8 >= x * x + z * z)
807
                {
808
                    x = d11;
809
                    y = d7;
810
                    z = d8;
811
                    this.setEntityBoundingBox(axisalignedbb3);
812
                }
813
            }
814
815
            this.worldObj.theProfiler.endSection();
816
            this.worldObj.theProfiler.startSection("rest");
817
            this.resetPositionToBB();
818
            this.isCollidedHorizontally = d3 != x || d5 != z;
819
            this.isCollidedVertically = d4 != y;
820
            this.onGround = this.isCollidedVertically && d4 < 0.0D;
821
            this.isCollided = this.isCollidedHorizontally || this.isCollidedVertically;
822
            int i = MathHelper.floor_double(this.posX);
823
            int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
824
            int k = MathHelper.floor_double(this.posZ);
825
            BlockPos blockpos = new BlockPos(i, j, k);
826
            Block block1 = this.worldObj.getBlockState(blockpos).getBlock();
827
828
            if (block1.getMaterial() == Material.air)
829
            {
830
                Block block = this.worldObj.getBlockState(blockpos.down()).getBlock();
831
832
                if (block instanceof BlockFence || block instanceof BlockWall || block instanceof BlockFenceGate)
833
                {
834
                    block1 = block;
835
                    blockpos = blockpos.down();
836
                }
837
            }
838
839
            this.updateFallState(y, this.onGround, block1, blockpos);
840
841
            if (d3 != x)
842
            {
843
                this.motionX = 0.0D;
844
            }
845
846
            if (d5 != z)
847
            {
848
                this.motionZ = 0.0D;
849
            }
850
851
            if (d4 != y)
852
            {
853
                block1.onLanded(this.worldObj, this);
854
            }
855
856
            if (this.canTriggerWalking() && !flag && this.ridingEntity == null)
857
            {
858
                double d12 = this.posX - d0;
859
                double d13 = this.posY - d1;
860
                double d14 = this.posZ - d2;
861
862
                if (block1 != Blocks.ladder)
863
                {
864
                    d13 = 0.0D;
865
                }
866
867
                if (block1 != null && this.onGround)
868
                {
869
                    block1.onEntityCollidedWithBlock(this.worldObj, blockpos, this);
870
                }
871
872
                this.distanceWalkedModified = (float)((double)this.distanceWalkedModified + (double)MathHelper.sqrt_double(d12 * d12 + d14 * d14) * 0.6D);
873
                this.distanceWalkedOnStepModified = (float)((double)this.distanceWalkedOnStepModified + (double)MathHelper.sqrt_double(d12 * d12 + d13 * d13 + d14 * d14) * 0.6D);
874
875
                if (this.distanceWalkedOnStepModified > (float)this.nextStepDistance && block1.getMaterial() != Material.air)
876
                {
877
                    this.nextStepDistance = (int)this.distanceWalkedOnStepModified + 1;
878
879
                    if (this.isInWater())
880
                    {
881
                        float f = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.35F;
882
883
                        if (f > 1.0F)
884
                        {
885
                            f = 1.0F;
886
                        }
887
888
                        this.playSound(this.getSwimSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
889
                    }
890
891
                    this.playStepSound(blockpos, block1);
892
                }
893
            }
894
895
            try
896
            {
897
                this.doBlockCollisions();
898
            }
899
            catch (Throwable throwable)
900
            {
901
                CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision");
902
                CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision");
903
                this.addEntityCrashInfo(crashreportcategory);
904
                throw new ReportedException(crashreport);
905
            }
906
907
            boolean flag2 = this.isWet();
908
909
            if (this.worldObj.isFlammableWithin(this.getEntityBoundingBox().contract(0.001D, 0.001D, 0.001D)))
910
            {
911
                this.dealFireDamage(1);
912
913
                if (!flag2)
914
                {
915
                    ++this.fire;
916
917
                    if (this.fire == 0)
918
                    {
919
                        this.setFire(8);
920
                    }
921
                }
922
            }
923
            else if (this.fire <= 0)
924
            {
925
                this.fire = -this.fireResistance;
926
            }
927
928
            if (flag2 && this.fire > 0)
929
            {
930
                this.playSound("random.fizz", 0.7F, 1.6F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
931
                this.fire = -this.fireResistance;
932
            }
933
934
            this.worldObj.theProfiler.endSection();
935
        }
936
    }
937
938
    /**
939
     * Resets the entity's position to the center (planar) and bottom (vertical) points of its bounding box.
940
     */
941
    private void resetPositionToBB()
942
    {
943
        this.posX = (this.getEntityBoundingBox().minX + this.getEntityBoundingBox().maxX) / 2.0D;
944
        this.posY = this.getEntityBoundingBox().minY;
945
        this.posZ = (this.getEntityBoundingBox().minZ + this.getEntityBoundingBox().maxZ) / 2.0D;
946
    }
947
948
    protected String getSwimSound()
949
    {
950
        return "game.neutral.swim";
951
    }
952
953
    protected void doBlockCollisions()
954
    {
955
        BlockPos blockpos = new BlockPos(this.getEntityBoundingBox().minX + 0.001D, this.getEntityBoundingBox().minY + 0.001D, this.getEntityBoundingBox().minZ + 0.001D);
956
        BlockPos blockpos1 = new BlockPos(this.getEntityBoundingBox().maxX - 0.001D, this.getEntityBoundingBox().maxY - 0.001D, this.getEntityBoundingBox().maxZ - 0.001D);
957
958
        if (this.worldObj.isAreaLoaded(blockpos, blockpos1))
959
        {
960
            for (int i = blockpos.getX(); i <= blockpos1.getX(); ++i)
961
            {
962
                for (int j = blockpos.getY(); j <= blockpos1.getY(); ++j)
963
                {
964
                    for (int k = blockpos.getZ(); k <= blockpos1.getZ(); ++k)
965
                    {
966
                        BlockPos blockpos2 = new BlockPos(i, j, k);
967
                        IBlockState iblockstate = this.worldObj.getBlockState(blockpos2);
968
969
                        try
970
                        {
971
                            iblockstate.getBlock().onEntityCollidedWithBlock(this.worldObj, blockpos2, iblockstate, this);
972
                        }
973
                        catch (Throwable throwable)
974
                        {
975
                            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block");
976
                            CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with");
977
                            CrashReportCategory.addBlockInfo(crashreportcategory, blockpos2, iblockstate);
978
                            throw new ReportedException(crashreport);
979
                        }
980
                    }
981
                }
982
            }
983
        }
984
    }
985
986
    protected void playStepSound(BlockPos pos, Block blockIn)
987
    {
988
        Block.SoundType block$soundtype = blockIn.stepSound;
989
990
        if (this.worldObj.getBlockState(pos.up()).getBlock() == Blocks.snow_layer)
991
        {
992
            block$soundtype = Blocks.snow_layer.stepSound;
993
            this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.15F, block$soundtype.getFrequency());
994
        }
995
        else if (!blockIn.getMaterial().isLiquid())
996
        {
997
            this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.15F, block$soundtype.getFrequency());
998
        }
999
    }
1000
1001
    public void playSound(String name, float volume, float pitch)
1002
    {
1003
        if (!this.isSilent())
1004
        {
1005
            this.worldObj.playSoundAtEntity(this, name, volume, pitch);
1006
        }
1007
    }
1008
1009
    /**
1010
     * @return True if this entity will not play sounds
1011
     */
1012
    public boolean isSilent()
1013
    {
1014
        return this.dataWatcher.getWatchableObjectByte(4) == 1;
1015
    }
1016
1017
    /**
1018
     * When set to true the entity will not play sounds.
1019
     */
1020
    public void setSilent(boolean isSilent)
1021
    {
1022
        this.dataWatcher.updateObject(4, Byte.valueOf((byte)(isSilent ? 1 : 0)));
1023
    }
1024
1025
    /**
1026
     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
1027
     * prevent them from trampling crops
1028
     */
1029
    protected boolean canTriggerWalking()
1030
    {
1031
        return true;
1032
    }
1033
1034
    protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
1035
    {
1036
        if (onGroundIn)
1037
        {
1038
            if (this.fallDistance > 0.0F)
1039
            {
1040
                if (blockIn != null)
1041
                {
1042
                    blockIn.onFallenUpon(this.worldObj, pos, this, this.fallDistance);
1043
                }
1044
                else
1045
                {
1046
                    this.fall(this.fallDistance, 1.0F);
1047
                }
1048
1049
                this.fallDistance = 0.0F;
1050
            }
1051
        }
1052
        else if (y < 0.0D)
1053
        {
1054
            this.fallDistance = (float)((double)this.fallDistance - y);
1055
        }
1056
    }
1057
1058
    /**
1059
     * Returns the collision bounding box for this entity
1060
     */
1061
    public AxisAlignedBB getCollisionBoundingBox()
1062
    {
1063
        return null;
1064
    }
1065
1066
    /**
1067
     * Will deal the specified amount of damage to the entity if the entity isn't immune to fire damage. Args:
1068
     * amountDamage
1069
     */
1070
    protected void dealFireDamage(int amount)
1071
    {
1072
        if (!this.isImmuneToFire)
1073
        {
1074
            this.attackEntityFrom(DamageSource.inFire, (float)amount);
1075
        }
1076
    }
1077
1078
    public final boolean isImmuneToFire()
1079
    {
1080
        return this.isImmuneToFire;
1081
    }
1082
1083
    public void fall(float distance, float damageMultiplier)
1084
    {
1085
        if (this.riddenByEntity != null)
1086
        {
1087
            this.riddenByEntity.fall(distance, damageMultiplier);
1088
        }
1089
    }
1090
1091
    /**
1092
     * Checks if this entity is either in water or on an open air block in rain (used in wolves).
1093
     */
1094
    public boolean isWet()
1095
    {
1096
        return this.inWater || this.worldObj.isRainingAt(new BlockPos(this.posX, this.posY, this.posZ)) || this.worldObj.isRainingAt(new BlockPos(this.posX, this.posY + (double)this.height, this.posZ));
1097
    }
1098
1099
    /**
1100
     * Checks if this entity is inside water (if inWater field is true as a result of handleWaterMovement() returning
1101
     * true)
1102
     */
1103
    public boolean isInWater()
1104
    {
1105
        return this.inWater;
1106
    }
1107
1108
    /**
1109
     * Returns if this entity is in water and will end up adding the waters velocity to the entity
1110
     */
1111
    public boolean handleWaterMovement()
1112
    {
1113
        if (this.worldObj.handleMaterialAcceleration(this.getEntityBoundingBox().expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D, 0.001D, 0.001D), Material.water, this))
1114
        {
1115
            if (!this.inWater && !this.firstUpdate)
1116
            {
1117
                this.resetHeight();
1118
            }
1119
1120
            this.fallDistance = 0.0F;
1121
            this.inWater = true;
1122
            this.fire = 0;
1123
        }
1124
        else
1125
        {
1126
            this.inWater = false;
1127
        }
1128
1129
        return this.inWater;
1130
    }
1131
1132
    /**
1133
     * sets the players height back to normal after doing things like sleeping and dieing
1134
     */
1135
    protected void resetHeight()
1136
    {
1137
        float f = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.2F;
1138
1139
        if (f > 1.0F)
1140
        {
1141
            f = 1.0F;
1142
        }
1143
1144
        this.playSound(this.getSplashSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
1145
        float f1 = (float)MathHelper.floor_double(this.getEntityBoundingBox().minY);
1146
1147
        for (int i = 0; (float)i < 1.0F + this.width * 20.0F; ++i)
1148
        {
1149
            float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1150
            float f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1151
            this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + (double)f2, (double)(f1 + 1.0F), this.posZ + (double)f3, this.motionX, this.motionY - (double)(this.rand.nextFloat() * 0.2F), this.motionZ, new int[0]);
1152
        }
1153
1154
        for (int j = 0; (float)j < 1.0F + this.width * 20.0F; ++j)
1155
        {
1156
            float f4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1157
            float f5 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
1158
            this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX + (double)f4, (double)(f1 + 1.0F), this.posZ + (double)f5, this.motionX, this.motionY, this.motionZ, new int[0]);
1159
        }
1160
    }
1161
1162
    /**
1163
     * Attempts to create sprinting particles if the entity is sprinting and not in water.
1164
     */
1165
    public void spawnRunningParticles()
1166
    {
1167
        if (this.isSprinting() && !this.isInWater())
1168
        {
1169
            this.createRunningParticles();
1170
        }
1171
    }
1172
1173
    protected void createRunningParticles()
1174
    {
1175
        int i = MathHelper.floor_double(this.posX);
1176
        int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
1177
        int k = MathHelper.floor_double(this.posZ);
1178
        BlockPos blockpos = new BlockPos(i, j, k);
1179
        IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
1180
        Block block = iblockstate.getBlock();
1181
1182
        if (block.getRenderType() != -1)
1183
        {
1184
            this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.getEntityBoundingBox().minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, -this.motionX * 4.0D, 1.5D, -this.motionZ * 4.0D, new int[] {Block.getStateId(iblockstate)});
1185
        }
1186
    }
1187
1188
    protected String getSplashSound()
1189
    {
1190
        return "game.neutral.swim.splash";
1191
    }
1192
1193
    /**
1194
     * Checks if the current block the entity is within of the specified material type
1195
     */
1196
    public boolean isInsideOfMaterial(Material materialIn)
1197
    {
1198
        double d0 = this.posY + (double)this.getEyeHeight();
1199
        BlockPos blockpos = new BlockPos(this.posX, d0, this.posZ);
1200
        IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
1201
        Block block = iblockstate.getBlock();
1202
1203
        if (block.getMaterial() == materialIn)
1204
        {
1205
            float f = BlockLiquid.getLiquidHeightPercent(iblockstate.getBlock().getMetaFromState(iblockstate)) - 0.11111111F;
1206
            float f1 = (float)(blockpos.getY() + 1) - f;
1207
            boolean flag = d0 < (double)f1;
1208
            return !flag && this instanceof EntityPlayer ? false : flag;
1209
        }
1210
        else
1211
        {
1212
            return false;
1213
        }
1214
    }
1215
1216
    public boolean isInLava()
1217
    {
1218
        return this.worldObj.isMaterialInBB(this.getEntityBoundingBox().expand(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.lava);
1219
    }
1220
1221
    /**
1222
     * Used in both water and by flying objects
1223
     */
1224
    public void moveFlying(float strafe, float forward, float friction)
1225
    {
1226
        float f = strafe * strafe + forward * forward;
1227
1228
        if (f >= 1.0E-4F)
1229
        {
1230
            f = MathHelper.sqrt_float(f);
1231
1232
            if (f < 1.0F)
1233
            {
1234
                f = 1.0F;
1235
            }
1236
1237
            f = friction / f;
1238
            strafe = strafe * f;
1239
            forward = forward * f;
1240
            float f1 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F);
1241
            float f2 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F);
1242
            this.motionX += (double)(strafe * f2 - forward * f1);
1243
            this.motionZ += (double)(forward * f2 + strafe * f1);
1244
        }
1245
    }
1246
1247
    public int getBrightnessForRender(float partialTicks)
1248
    {
1249
        BlockPos blockpos = new BlockPos(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
1250
        return this.worldObj.isBlockLoaded(blockpos) ? this.worldObj.getCombinedLight(blockpos, 0) : 0;
1251
    }
1252
1253
    /**
1254
     * Gets how bright this entity is.
1255
     */
1256
    public float getBrightness(float partialTicks)
1257
    {
1258
        BlockPos blockpos = new BlockPos(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
1259
        return this.worldObj.isBlockLoaded(blockpos) ? this.worldObj.getLightBrightness(blockpos) : 0.0F;
1260
    }
1261
1262
    /**
1263
     * Sets the reference to the World object.
1264
     */
1265
    public void setWorld(World worldIn)
1266
    {
1267
        this.worldObj = worldIn;
1268
    }
1269
1270
    /**
1271
     * Sets the entity's position and rotation.
1272
     */
1273
    public void setPositionAndRotation(double x, double y, double z, float yaw, float pitch)
1274
    {
1275
        this.prevPosX = this.posX = x;
1276
        this.prevPosY = this.posY = y;
1277
        this.prevPosZ = this.posZ = z;
1278
        this.prevRotationYaw = this.rotationYaw = yaw;
1279
        this.prevRotationPitch = this.rotationPitch = pitch;
1280
        double d0 = (double)(this.prevRotationYaw - yaw);
1281
1282
        if (d0 < -180.0D)
1283
        {
1284
            this.prevRotationYaw += 360.0F;
1285
        }
1286
1287
        if (d0 >= 180.0D)
1288
        {
1289
            this.prevRotationYaw -= 360.0F;
1290
        }
1291
1292
        this.setPosition(this.posX, this.posY, this.posZ);
1293
        this.setRotation(yaw, pitch);
1294
    }
1295
1296
    public void moveToBlockPosAndAngles(BlockPos pos, float rotationYawIn, float rotationPitchIn)
1297
    {
1298
        this.setLocationAndAngles((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, rotationYawIn, rotationPitchIn);
1299
    }
1300
1301
    /**
1302
     * Sets the location and Yaw/Pitch of an entity in the world
1303
     */
1304
    public void setLocationAndAngles(double x, double y, double z, float yaw, float pitch)
1305
    {
1306
        this.lastTickPosX = this.prevPosX = this.posX = x;
1307
        this.lastTickPosY = this.prevPosY = this.posY = y;
1308
        this.lastTickPosZ = this.prevPosZ = this.posZ = z;
1309
        this.rotationYaw = yaw;
1310
        this.rotationPitch = pitch;
1311
        this.setPosition(this.posX, this.posY, this.posZ);
1312
    }
1313
1314
    /**
1315
     * Returns the distance to the entity. Args: entity
1316
     */
1317
    public float getDistanceToEntity(Entity entityIn)
1318
    {
1319
        float f = (float)(this.posX - entityIn.posX);
1320
        float f1 = (float)(this.posY - entityIn.posY);
1321
        float f2 = (float)(this.posZ - entityIn.posZ);
1322
        return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
1323
    }
1324
1325
    /**
1326
     * Gets the squared distance to the position. Args: x, y, z
1327
     */
1328
    public double getDistanceSq(double x, double y, double z)
1329
    {
1330
        double d0 = this.posX - x;
1331
        double d1 = this.posY - y;
1332
        double d2 = this.posZ - z;
1333
        return d0 * d0 + d1 * d1 + d2 * d2;
1334
    }
1335
1336
    public double getDistanceSq(BlockPos pos)
1337
    {
1338
        return pos.distanceSq(this.posX, this.posY, this.posZ);
1339
    }
1340
1341
    public double getDistanceSqToCenter(BlockPos pos)
1342
    {
1343
        return pos.distanceSqToCenter(this.posX, this.posY, this.posZ);
1344
    }
1345
1346
    /**
1347
     * Gets the distance to the position. Args: x, y, z
1348
     */
1349
    public double getDistance(double x, double y, double z)
1350
    {
1351
        double d0 = this.posX - x;
1352
        double d1 = this.posY - y;
1353
        double d2 = this.posZ - z;
1354
        return (double)MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2);
1355
    }
1356
1357
    /**
1358
     * Returns the squared distance to the entity. Args: entity
1359
     */
1360
    public double getDistanceSqToEntity(Entity entityIn)
1361
    {
1362
        double d0 = this.posX - entityIn.posX;
1363
        double d1 = this.posY - entityIn.posY;
1364
        double d2 = this.posZ - entityIn.posZ;
1365
        return d0 * d0 + d1 * d1 + d2 * d2;
1366
    }
1367
1368
    /**
1369
     * Called by a player entity when they collide with an entity
1370
     */
1371
    public void onCollideWithPlayer(EntityPlayer entityIn)
1372
    {
1373
    }
1374
1375
    /**
1376
     * Applies a velocity to each of the entities pushing them away from each other. Args: entity
1377
     */
1378
    public void applyEntityCollision(Entity entityIn)
1379
    {
1380
        if (entityIn.riddenByEntity != this && entityIn.ridingEntity != this)
1381
        {
1382
            if (!entityIn.noClip && !this.noClip)
1383
            {
1384
                double d0 = entityIn.posX - this.posX;
1385
                double d1 = entityIn.posZ - this.posZ;
1386
                double d2 = MathHelper.abs_max(d0, d1);
1387
1388
                if (d2 >= 0.009999999776482582D)
1389
                {
1390
                    d2 = (double)MathHelper.sqrt_double(d2);
1391
                    d0 = d0 / d2;
1392
                    d1 = d1 / d2;
1393
                    double d3 = 1.0D / d2;
1394
1395
                    if (d3 > 1.0D)
1396
                    {
1397
                        d3 = 1.0D;
1398
                    }
1399
1400
                    d0 = d0 * d3;
1401
                    d1 = d1 * d3;
1402
                    d0 = d0 * 0.05000000074505806D;
1403
                    d1 = d1 * 0.05000000074505806D;
1404
                    d0 = d0 * (double)(1.0F - this.entityCollisionReduction);
1405
                    d1 = d1 * (double)(1.0F - this.entityCollisionReduction);
1406
1407
                    if (this.riddenByEntity == null)
1408
                    {
1409
                        this.addVelocity(-d0, 0.0D, -d1);
1410
                    }
1411
1412
                    if (entityIn.riddenByEntity == null)
1413
                    {
1414
                        entityIn.addVelocity(d0, 0.0D, d1);
1415
                    }
1416
                }
1417
            }
1418
        }
1419
    }
1420
1421
    /**
1422
     * Adds to the current velocity of the entity. Args: x, y, z
1423
     */
1424
    public void addVelocity(double x, double y, double z)
1425
    {
1426
        this.motionX += x;
1427
        this.motionY += y;
1428
        this.motionZ += z;
1429
        this.isAirBorne = true;
1430
    }
1431
1432
    /**
1433
     * Sets that this entity has been attacked.
1434
     */
1435
    protected void setBeenAttacked()
1436
    {
1437
        this.velocityChanged = true;
1438
    }
1439
1440
    /**
1441
     * Called when the entity is attacked.
1442
     */
1443
    public boolean attackEntityFrom(DamageSource source, float amount)
1444
    {
1445
        if (this.isEntityInvulnerable(source))
1446
        {
1447
            return false;
1448
        }
1449
        else
1450
        {
1451
            this.setBeenAttacked();
1452
            return false;
1453
        }
1454
    }
1455
1456
    /**
1457
     * interpolated look vector
1458
     */
1459
    public Vec3 getLook(float partialTicks)
1460
    {
1461
        if (partialTicks == 1.0F)
1462
        {
1463
            return this.getVectorForRotation(this.rotationPitch, this.rotationYaw);
1464
        }
1465
        else
1466
        {
1467
            float f = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * partialTicks;
1468
            float f1 = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * partialTicks;
1469
            return this.getVectorForRotation(f, f1);
1470
        }
1471
    }
1472
1473
    /**
1474
     * Creates a Vec3 using the pitch and yaw of the entities rotation.
1475
     */
1476
    protected final Vec3 getVectorForRotation(float pitch, float yaw)
1477
    {
1478
        float f = MathHelper.cos(-yaw * 0.017453292F - (float)Math.PI);
1479
        float f1 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
1480
        float f2 = -MathHelper.cos(-pitch * 0.017453292F);
1481
        float f3 = MathHelper.sin(-pitch * 0.017453292F);
1482
        return new Vec3((double)(f1 * f2), (double)f3, (double)(f * f2));
1483
    }
1484
1485
    public Vec3 getPositionEyes(float partialTicks)
1486
    {
1487
        if (partialTicks == 1.0F)
1488
        {
1489
            return new Vec3(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
1490
        }
1491
        else
1492
        {
1493
            double d0 = this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks;
1494
            double d1 = this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks + (double)this.getEyeHeight();
1495
            double d2 = this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks;
1496
            return new Vec3(d0, d1, d2);
1497
        }
1498
    }
1499
1500
    public MovingObjectPosition rayTrace(double blockReachDistance, float partialTicks)
1501
    {
1502
        Vec3 vec3 = this.getPositionEyes(partialTicks);
1503
        Vec3 vec31 = this.getLook(partialTicks);
1504
        Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
1505
        return this.worldObj.rayTraceBlocks(vec3, vec32, false, false, true);
1506
    }
1507
1508
    /**
1509
     * Returns true if other Entities should be prevented from moving through this Entity.
1510
     */
1511
    public boolean canBeCollidedWith()
1512
    {
1513
        return false;
1514
    }
1515
1516
    /**
1517
     * Returns true if this entity should push and be pushed by other entities when colliding.
1518
     */
1519
    public boolean canBePushed()
1520
    {
1521
        return false;
1522
    }
1523
1524
    /**
1525
     * Adds a value to the player score. Currently not actually used and the entity passed in does nothing. Args:
1526
     * entity, scoreToAdd
1527
     */
1528
    public void addToPlayerScore(Entity entityIn, int amount)
1529
    {
1530
    }
1531
1532
    public boolean isInRangeToRender3d(double x, double y, double z)
1533
    {
1534
        double d0 = this.posX - x;
1535
        double d1 = this.posY - y;
1536
        double d2 = this.posZ - z;
1537
        double d3 = d0 * d0 + d1 * d1 + d2 * d2;
1538
        return this.isInRangeToRenderDist(d3);
1539
    }
1540
1541
    /**
1542
     * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
1543
     * length * 64 * renderDistanceWeight Args: distance
1544
     */
1545
    public boolean isInRangeToRenderDist(double distance)
1546
    {
1547
        double d0 = this.getEntityBoundingBox().getAverageEdgeLength();
1548
1549
        if (Double.isNaN(d0))
1550
        {
1551
            d0 = 1.0D;
1552
        }
1553
1554
        d0 = d0 * 64.0D * this.renderDistanceWeight;
1555
        return distance < d0 * d0;
1556
    }
1557
1558
    /**
1559
     * Like writeToNBTOptional but does not check if the entity is ridden. Used for saving ridden entities with their
1560
     * riders.
1561
     */
1562
    public boolean writeMountToNBT(NBTTagCompound tagCompund)
1563
    {
1564
        String s = this.getEntityString();
1565
1566
        if (!this.isDead && s != null)
1567
        {
1568
            tagCompund.setString("id", s);
1569
            this.writeToNBT(tagCompund);
1570
            return true;
1571
        }
1572
        else
1573
        {
1574
            return false;
1575
        }
1576
    }
1577
1578
    /**
1579
     * Either write this entity to the NBT tag given and return true, or return false without doing anything. If this
1580
     * returns false the entity is not saved on disk. Ridden entities return false here as they are saved with their
1581
     * rider.
1582
     */
1583
    public boolean writeToNBTOptional(NBTTagCompound tagCompund)
1584
    {
1585
        String s = this.getEntityString();
1586
1587
        if (!this.isDead && s != null && this.riddenByEntity == null)
1588
        {
1589
            tagCompund.setString("id", s);
1590
            this.writeToNBT(tagCompund);
1591
            return true;
1592
        }
1593
        else
1594
        {
1595
            return false;
1596
        }
1597
    }
1598
1599
    /**
1600
     * Save the entity to NBT (calls an abstract helper method to write extra data)
1601
     */
1602
    public void writeToNBT(NBTTagCompound tagCompund)
1603
    {
1604
        try
1605
        {
1606
            tagCompund.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY, this.posZ}));
1607
            tagCompund.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
1608
            tagCompund.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch}));
1609
            tagCompund.setFloat("FallDistance", this.fallDistance);
1610
            tagCompund.setShort("Fire", (short)this.fire);
1611
            tagCompund.setShort("Air", (short)this.getAir());
1612
            tagCompund.setBoolean("OnGround", this.onGround);
1613
            tagCompund.setInteger("Dimension", this.dimension);
1614
            tagCompund.setBoolean("Invulnerable", this.invulnerable);
1615
            tagCompund.setInteger("PortalCooldown", this.timeUntilPortal);
1616
            tagCompund.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits());
1617
            tagCompund.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits());
1618
1619
            if (this.getCustomNameTag() != null && this.getCustomNameTag().length() > 0)
1620
            {
1621
                tagCompund.setString("CustomName", this.getCustomNameTag());
1622
                tagCompund.setBoolean("CustomNameVisible", this.getAlwaysRenderNameTag());
1623
            }
1624
1625
            this.cmdResultStats.writeStatsToNBT(tagCompund);
1626
1627
            if (this.isSilent())
1628
            {
1629
                tagCompund.setBoolean("Silent", this.isSilent());
1630
            }
1631
1632
            this.writeEntityToNBT(tagCompund);
1633
1634
            if (this.ridingEntity != null)
1635
            {
1636
                NBTTagCompound nbttagcompound = new NBTTagCompound();
1637
1638
                if (this.ridingEntity.writeMountToNBT(nbttagcompound))
1639
                {
1640
                    tagCompund.setTag("Riding", nbttagcompound);
1641
                }
1642
            }
1643
        }
1644
        catch (Throwable throwable)
1645
        {
1646
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Saving entity NBT");
1647
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being saved");
1648
            this.addEntityCrashInfo(crashreportcategory);
1649
            throw new ReportedException(crashreport);
1650
        }
1651
    }
1652
1653
    /**
1654
     * Reads the entity from NBT (calls an abstract helper method to read specialized data)
1655
     */
1656
    public void readFromNBT(NBTTagCompound tagCompund)
1657
    {
1658
        try
1659
        {
1660
            NBTTagList nbttaglist = tagCompund.getTagList("Pos", 6);
1661
            NBTTagList nbttaglist1 = tagCompund.getTagList("Motion", 6);
1662
            NBTTagList nbttaglist2 = tagCompund.getTagList("Rotation", 5);
1663
            this.motionX = nbttaglist1.getDoubleAt(0);
1664
            this.motionY = nbttaglist1.getDoubleAt(1);
1665
            this.motionZ = nbttaglist1.getDoubleAt(2);
1666
1667
            if (Math.abs(this.motionX) > 10.0D)
1668
            {
1669
                this.motionX = 0.0D;
1670
            }
1671
1672
            if (Math.abs(this.motionY) > 10.0D)
1673
            {
1674
                this.motionY = 0.0D;
1675
            }
1676
1677
            if (Math.abs(this.motionZ) > 10.0D)
1678
            {
1679
                this.motionZ = 0.0D;
1680
            }
1681
1682
            this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.getDoubleAt(0);
1683
            this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.getDoubleAt(1);
1684
            this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.getDoubleAt(2);
1685
            this.prevRotationYaw = this.rotationYaw = nbttaglist2.getFloatAt(0);
1686
            this.prevRotationPitch = this.rotationPitch = nbttaglist2.getFloatAt(1);
1687
            this.setRotationYawHead(this.rotationYaw);
1688
            this.setRenderYawOffset(this.rotationYaw);
1689
            this.fallDistance = tagCompund.getFloat("FallDistance");
1690
            this.fire = tagCompund.getShort("Fire");
1691
            this.setAir(tagCompund.getShort("Air"));
1692
            this.onGround = tagCompund.getBoolean("OnGround");
1693
            this.dimension = tagCompund.getInteger("Dimension");
1694
            this.invulnerable = tagCompund.getBoolean("Invulnerable");
1695
            this.timeUntilPortal = tagCompund.getInteger("PortalCooldown");
1696
1697
            if (tagCompund.hasKey("UUIDMost", 4) && tagCompund.hasKey("UUIDLeast", 4))
1698
            {
1699
                this.entityUniqueID = new UUID(tagCompund.getLong("UUIDMost"), tagCompund.getLong("UUIDLeast"));
1700
            }
1701
            else if (tagCompund.hasKey("UUID", 8))
1702
            {
1703
                this.entityUniqueID = UUID.fromString(tagCompund.getString("UUID"));
1704
            }
1705
1706
            this.setPosition(this.posX, this.posY, this.posZ);
1707
            this.setRotation(this.rotationYaw, this.rotationPitch);
1708
1709
            if (tagCompund.hasKey("CustomName", 8) && tagCompund.getString("CustomName").length() > 0)
1710
            {
1711
                this.setCustomNameTag(tagCompund.getString("CustomName"));
1712
            }
1713
1714
            this.setAlwaysRenderNameTag(tagCompund.getBoolean("CustomNameVisible"));
1715
            this.cmdResultStats.readStatsFromNBT(tagCompund);
1716
            this.setSilent(tagCompund.getBoolean("Silent"));
1717
            this.readEntityFromNBT(tagCompund);
1718
1719
            if (this.shouldSetPosAfterLoading())
1720
            {
1721
                this.setPosition(this.posX, this.posY, this.posZ);
1722
            }
1723
        }
1724
        catch (Throwable throwable)
1725
        {
1726
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Loading entity NBT");
1727
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being loaded");
1728
            this.addEntityCrashInfo(crashreportcategory);
1729
            throw new ReportedException(crashreport);
1730
        }
1731
    }
1732
1733
    protected boolean shouldSetPosAfterLoading()
1734
    {
1735
        return true;
1736
    }
1737
1738
    /**
1739
     * Returns the string that identifies this Entity's class
1740
     */
1741
    protected final String getEntityString()
1742
    {
1743
        return EntityList.getEntityString(this);
1744
    }
1745
1746
    /**
1747
     * (abstract) Protected helper method to read subclass entity data from NBT.
1748
     */
1749
    protected abstract void readEntityFromNBT(NBTTagCompound tagCompund);
1750
1751
    /**
1752
     * (abstract) Protected helper method to write subclass entity data to NBT.
1753
     */
1754
    protected abstract void writeEntityToNBT(NBTTagCompound tagCompound);
1755
1756
    public void onChunkLoad()
1757
    {
1758
    }
1759
1760
    /**
1761
     * creates a NBT list from the array of doubles passed to this function
1762
     */
1763
    protected NBTTagList newDoubleNBTList(double... numbers)
1764
    {
1765
        NBTTagList nbttaglist = new NBTTagList();
1766
1767
        for (double d0 : numbers)
1768
        {
1769
            nbttaglist.appendTag(new NBTTagDouble(d0));
1770
        }
1771
1772
        return nbttaglist;
1773
    }
1774
1775
    /**
1776
     * Returns a new NBTTagList filled with the specified floats
1777
     */
1778
    protected NBTTagList newFloatNBTList(float... numbers)
1779
    {
1780
        NBTTagList nbttaglist = new NBTTagList();
1781
1782
        for (float f : numbers)
1783
        {
1784
            nbttaglist.appendTag(new NBTTagFloat(f));
1785
        }
1786
1787
        return nbttaglist;
1788
    }
1789
1790
    public EntityItem dropItem(Item itemIn, int size)
1791
    {
1792
        return this.dropItemWithOffset(itemIn, size, 0.0F);
1793
    }
1794
1795
    public EntityItem dropItemWithOffset(Item itemIn, int size, float offsetY)
1796
    {
1797
        return this.entityDropItem(new ItemStack(itemIn, size, 0), offsetY);
1798
    }
1799
1800
    /**
1801
     * Drops an item at the position of the entity.
1802
     */
1803
    public EntityItem entityDropItem(ItemStack itemStackIn, float offsetY)
1804
    {
1805
        if (itemStackIn.stackSize != 0 && itemStackIn.getItem() != null)
1806
        {
1807
            EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + (double)offsetY, this.posZ, itemStackIn);
1808
            entityitem.setDefaultPickupDelay();
1809
            this.worldObj.spawnEntityInWorld(entityitem);
1810
            return entityitem;
1811
        }
1812
        else
1813
        {
1814
            return null;
1815
        }
1816
    }
1817
1818
    /**
1819
     * Checks whether target entity is alive.
1820
     */
1821
    public boolean isEntityAlive()
1822
    {
1823
        return !this.isDead;
1824
    }
1825
1826
    /**
1827
     * Checks if this entity is inside of an opaque block
1828
     */
1829
    public boolean isEntityInsideOpaqueBlock()
1830
    {
1831
        if (this.noClip)
1832
        {
1833
            return false;
1834
        }
1835
        else
1836
        {
1837
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
1838
1839
            for (int i = 0; i < 8; ++i)
1840
            {
1841
                int j = MathHelper.floor_double(this.posY + (double)(((float)((i >> 0) % 2) - 0.5F) * 0.1F) + (double)this.getEyeHeight());
1842
                int k = MathHelper.floor_double(this.posX + (double)(((float)((i >> 1) % 2) - 0.5F) * this.width * 0.8F));
1843
                int l = MathHelper.floor_double(this.posZ + (double)(((float)((i >> 2) % 2) - 0.5F) * this.width * 0.8F));
1844
1845
                if (blockpos$mutableblockpos.getX() != k || blockpos$mutableblockpos.getY() != j || blockpos$mutableblockpos.getZ() != l)
1846
                {
1847
                    blockpos$mutableblockpos.set(k, j, l);
1848
1849
                    if (this.worldObj.getBlockState(blockpos$mutableblockpos).getBlock().isVisuallyOpaque())
1850
                    {
1851
                        return true;
1852
                    }
1853
                }
1854
            }
1855
1856
            return false;
1857
        }
1858
    }
1859
1860
    /**
1861
     * First layer of player interaction
1862
     */
1863
    public boolean interactFirst(EntityPlayer playerIn)
1864
    {
1865
        return false;
1866
    }
1867
1868
    /**
1869
     * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be
1870
     * pushable on contact, like boats or minecarts.
1871
     */
1872
    public AxisAlignedBB getCollisionBox(Entity entityIn)
1873
    {
1874
        return null;
1875
    }
1876
1877
    /**
1878
     * Handles updating while being ridden by an entity
1879
     */
1880
    public void updateRidden()
1881
    {
1882
        if (this.ridingEntity.isDead)
1883
        {
1884
            this.ridingEntity = null;
1885
        }
1886
        else
1887
        {
1888
            this.motionX = 0.0D;
1889
            this.motionY = 0.0D;
1890
            this.motionZ = 0.0D;
1891
            this.onUpdate();
1892
1893
            if (this.ridingEntity != null)
1894
            {
1895
                this.ridingEntity.updateRiderPosition();
1896
                this.entityRiderYawDelta += (double)(this.ridingEntity.rotationYaw - this.ridingEntity.prevRotationYaw);
1897
1898
                for (this.entityRiderPitchDelta += (double)(this.ridingEntity.rotationPitch - this.ridingEntity.prevRotationPitch); this.entityRiderYawDelta >= 180.0D; this.entityRiderYawDelta -= 360.0D)
1899
                {
1900
                    ;
1901
                }
1902
1903
                while (this.entityRiderYawDelta < -180.0D)
1904
                {
1905
                    this.entityRiderYawDelta += 360.0D;
1906
                }
1907
1908
                while (this.entityRiderPitchDelta >= 180.0D)
1909
                {
1910
                    this.entityRiderPitchDelta -= 360.0D;
1911
                }
1912
1913
                while (this.entityRiderPitchDelta < -180.0D)
1914
                {
1915
                    this.entityRiderPitchDelta += 360.0D;
1916
                }
1917
1918
                double d0 = this.entityRiderYawDelta * 0.5D;
1919
                double d1 = this.entityRiderPitchDelta * 0.5D;
1920
                float f = 10.0F;
1921
1922
                if (d0 > (double)f)
1923
                {
1924
                    d0 = (double)f;
1925
                }
1926
1927
                if (d0 < (double)(-f))
1928
                {
1929
                    d0 = (double)(-f);
1930
                }
1931
1932
                if (d1 > (double)f)
1933
                {
1934
                    d1 = (double)f;
1935
                }
1936
1937
                if (d1 < (double)(-f))
1938
                {
1939
                    d1 = (double)(-f);
1940
                }
1941
1942
                this.entityRiderYawDelta -= d0;
1943
                this.entityRiderPitchDelta -= d1;
1944
            }
1945
        }
1946
    }
1947
1948
    public void updateRiderPosition()
1949
    {
1950
        if (this.riddenByEntity != null)
1951
        {
1952
            this.riddenByEntity.setPosition(this.posX, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ);
1953
        }
1954
    }
1955
1956
    /**
1957
     * Returns the Y Offset of this entity.
1958
     */
1959
    public double getYOffset()
1960
    {
1961
        return 0.0D;
1962
    }
1963
1964
    /**
1965
     * Returns the Y offset from the entity's position for any entity riding this one.
1966
     */
1967
    public double getMountedYOffset()
1968
    {
1969
        return (double)this.height * 0.75D;
1970
    }
1971
1972
    /**
1973
     * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
1974
     */
1975
    public void mountEntity(Entity entityIn)
1976
    {
1977
        this.entityRiderPitchDelta = 0.0D;
1978
        this.entityRiderYawDelta = 0.0D;
1979
1980
        if (entityIn == null)
1981
        {
1982
            if (this.ridingEntity != null)
1983
            {
1984
                this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.getEntityBoundingBox().minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch);
1985
                this.ridingEntity.riddenByEntity = null;
1986
            }
1987
1988
            this.ridingEntity = null;
1989
        }
1990
        else
1991
        {
1992
            if (this.ridingEntity != null)
1993
            {
1994
                this.ridingEntity.riddenByEntity = null;
1995
            }
1996
1997
            if (entityIn != null)
1998
            {
1999
                for (Entity entity = entityIn.ridingEntity; entity != null; entity = entity.ridingEntity)
2000
                {
2001
                    if (entity == this)
2002
                    {
2003
                        return;
2004
                    }
2005
                }
2006
            }
2007
2008
            this.ridingEntity = entityIn;
2009
            entityIn.riddenByEntity = this;
2010
        }
2011
    }
2012
2013
    public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
2014
    {
2015
        this.setPosition(x, y, z);
2016
        this.setRotation(yaw, pitch);
2017
        List<AxisAlignedBB> list = this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox().contract(0.03125D, 0.0D, 0.03125D));
2018
2019
        if (!list.isEmpty())
2020
        {
2021
            double d0 = 0.0D;
2022
2023
            for (AxisAlignedBB axisalignedbb : list)
2024
            {
2025
                if (axisalignedbb.maxY > d0)
2026
                {
2027
                    d0 = axisalignedbb.maxY;
2028
                }
2029
            }
2030
2031
            y = y + (d0 - this.getEntityBoundingBox().minY);
2032
            this.setPosition(x, y, z);
2033
        }
2034
    }
2035
2036
    public float getCollisionBorderSize()
2037
    {
2038
        return 0.1F;
2039
    }
2040
2041
    /**
2042
     * returns a (normalized) vector of where this entity is looking
2043
     */
2044
    public Vec3 getLookVec()
2045
    {
2046
        return null;
2047
    }
2048
2049
    /**
2050
     * Marks the entity as being inside a portal, activating teleportation logic in onEntityUpdate() in the following
2051
     * tick(s).
2052
     *  
2053
     * @param pos The postion of the portal that the entity is in
2054
     */
2055
    public void setPortal(BlockPos pos)
2056
    {
2057
        if (this.timeUntilPortal > 0)
2058
        {
2059
            this.timeUntilPortal = this.getPortalCooldown();
2060
        }
2061
        else
2062
        {
2063
            if (!this.worldObj.isRemote && !pos.equals(this.lastPortalPos))
2064
            {
2065
                this.lastPortalPos = pos;
2066
                BlockPattern.PatternHelper blockpattern$patternhelper = Blocks.portal.func_181089_f(this.worldObj, pos);
2067
                double d0 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.getPos().getZ() : (double)blockpattern$patternhelper.getPos().getX();
2068
                double d1 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? this.posZ : this.posX;
2069
                d1 = Math.abs(MathHelper.func_181160_c(d1 - (double)(blockpattern$patternhelper.getFinger().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ? 1 : 0), d0, d0 - (double)blockpattern$patternhelper.func_181118_d()));
2070
                double d2 = MathHelper.func_181160_c(this.posY - 1.0D, (double)blockpattern$patternhelper.getPos().getY(), (double)(blockpattern$patternhelper.getPos().getY() - blockpattern$patternhelper.func_181119_e()));
2071
                this.lastPortalVec = new Vec3(d1, d2, 0.0D);
2072
                this.teleportDirection = blockpattern$patternhelper.getFinger();
2073
            }
2074
2075
            this.inPortal = true;
2076
        }
2077
    }
2078
2079
    /**
2080
     * Return the amount of cooldown before this entity can use a portal again.
2081
     */
2082
    public int getPortalCooldown()
2083
    {
2084
        return 300;
2085
    }
2086
2087
    /**
2088
     * Sets the velocity to the args. Args: x, y, z
2089
     */
2090
    public void setVelocity(double x, double y, double z)
2091
    {
2092
        this.motionX = x;
2093
        this.motionY = y;
2094
        this.motionZ = z;
2095
    }
2096
2097
    public void handleStatusUpdate(byte id)
2098
    {
2099
    }
2100
2101
    /**
2102
     * Setups the entity to do the hurt animation. Only used by packets in multiplayer.
2103
     */
2104
    public void performHurtAnimation()
2105
    {
2106
    }
2107
2108
    /**
2109
     * returns the inventory of this entity (only used in EntityPlayerMP it seems)
2110
     */
2111
    public ItemStack[] getInventory()
2112
    {
2113
        return null;
2114
    }
2115
2116
    /**
2117
     * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
2118
     */
2119
    public void setCurrentItemOrArmor(int slotIn, ItemStack stack)
2120
    {
2121
    }
2122
2123
    /**
2124
     * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
2125
     */
2126
    public boolean isBurning()
2127
    {
2128
        boolean flag = this.worldObj != null && this.worldObj.isRemote;
2129
        return !this.isImmuneToFire && (this.fire > 0 || flag && this.getFlag(0));
2130
    }
2131
2132
    /**
2133
     * Returns true if the entity is riding another entity, used by render to rotate the legs to be in 'sit' position
2134
     * for players.
2135
     */
2136
    public boolean isRiding()
2137
    {
2138
        return this.ridingEntity != null;
2139
    }
2140
2141
    /**
2142
     * Returns if this entity is sneaking.
2143
     */
2144
    public boolean isSneaking()
2145
    {
2146
        return this.getFlag(1);
2147
    }
2148
2149
    /**
2150
     * Sets the sneaking flag.
2151
     */
2152
    public void setSneaking(boolean sneaking)
2153
    {
2154
        this.setFlag(1, sneaking);
2155
    }
2156
2157
    /**
2158
     * Get if the Entity is sprinting.
2159
     */
2160
    public boolean isSprinting()
2161
    {
2162
        return this.getFlag(3);
2163
    }
2164
2165
    /**
2166
     * Set sprinting switch for Entity.
2167
     */
2168
    public void setSprinting(boolean sprinting)
2169
    {
2170
        this.setFlag(3, sprinting);
2171
    }
2172
2173
    public boolean isInvisible()
2174
    {
2175
        return this.getFlag(5);
2176
    }
2177
2178
    /**
2179
     * Only used by renderer in EntityLivingBase subclasses.
2180
     * Determines if an entity is visible or not to a specfic player, if the entity is normally invisible.
2181
     * For EntityLivingBase subclasses, returning false when invisible will render the entity semitransparent.
2182
     */
2183
    public boolean isInvisibleToPlayer(EntityPlayer player)
2184
    {
2185
        return player.isSpectator() ? false : this.isInvisible();
2186
    }
2187
2188
    public void setInvisible(boolean invisible)
2189
    {
2190
        this.setFlag(5, invisible);
2191
    }
2192
2193
    public boolean isEating()
2194
    {
2195
        return this.getFlag(4);
2196
    }
2197
2198
    public void setEating(boolean eating)
2199
    {
2200
        this.setFlag(4, eating);
2201
    }
2202
2203
    /**
2204
     * Returns true if the flag is active for the entity. Known flags: 0) is burning; 1) is sneaking; 2) is riding
2205
     * something; 3) is sprinting; 4) is eating
2206
     */
2207
    protected boolean getFlag(int flag)
2208
    {
2209
        return (this.dataWatcher.getWatchableObjectByte(0) & 1 << flag) != 0;
2210
    }
2211
2212
    /**
2213
     * Enable or disable a entity flag, see getEntityFlag to read the know flags.
2214
     */
2215
    protected void setFlag(int flag, boolean set)
2216
    {
2217
        byte b0 = this.dataWatcher.getWatchableObjectByte(0);
2218
2219
        if (set)
2220
        {
2221
            this.dataWatcher.updateObject(0, Byte.valueOf((byte)(b0 | 1 << flag)));
2222
        }
2223
        else
2224
        {
2225
            this.dataWatcher.updateObject(0, Byte.valueOf((byte)(b0 & ~(1 << flag))));
2226
        }
2227
    }
2228
2229
    public int getAir()
2230
    {
2231
        return this.dataWatcher.getWatchableObjectShort(1);
2232
    }
2233
2234
    public void setAir(int air)
2235
    {
2236
        this.dataWatcher.updateObject(1, Short.valueOf((short)air));
2237
    }
2238
2239
    /**
2240
     * Called when a lightning bolt hits the entity.
2241
     */
2242
    public void onStruckByLightning(EntityLightningBolt lightningBolt)
2243
    {
2244
        this.attackEntityFrom(DamageSource.lightningBolt, 5.0F);
2245
        ++this.fire;
2246
2247
        if (this.fire == 0)
2248
        {
2249
            this.setFire(8);
2250
        }
2251
    }
2252
2253
    /**
2254
     * This method gets called when the entity kills another one.
2255
     */
2256
    public void onKillEntity(EntityLivingBase entityLivingIn)
2257
    {
2258
    }
2259
2260
    protected boolean pushOutOfBlocks(double x, double y, double z)
2261
    {
2262
        BlockPos blockpos = new BlockPos(x, y, z);
2263
        double d0 = x - (double)blockpos.getX();
2264
        double d1 = y - (double)blockpos.getY();
2265
        double d2 = z - (double)blockpos.getZ();
2266
        List<AxisAlignedBB> list = this.worldObj.getCollisionBoxes(this.getEntityBoundingBox());
2267
2268
        if (list.isEmpty() && !this.worldObj.isBlockFullCube(blockpos))
2269
        {
2270
            return false;
2271
        }
2272
        else
2273
        {
2274
            int i = 3;
2275
            double d3 = 9999.0D;
2276
2277
            if (!this.worldObj.isBlockFullCube(blockpos.west()) && d0 < d3)
2278
            {
2279
                d3 = d0;
2280
                i = 0;
2281
            }
2282
2283
            if (!this.worldObj.isBlockFullCube(blockpos.east()) && 1.0D - d0 < d3)
2284
            {
2285
                d3 = 1.0D - d0;
2286
                i = 1;
2287
            }
2288
2289
            if (!this.worldObj.isBlockFullCube(blockpos.up()) && 1.0D - d1 < d3)
2290
            {
2291
                d3 = 1.0D - d1;
2292
                i = 3;
2293
            }
2294
2295
            if (!this.worldObj.isBlockFullCube(blockpos.north()) && d2 < d3)
2296
            {
2297
                d3 = d2;
2298
                i = 4;
2299
            }
2300
2301
            if (!this.worldObj.isBlockFullCube(blockpos.south()) && 1.0D - d2 < d3)
2302
            {
2303
                d3 = 1.0D - d2;
2304
                i = 5;
2305
            }
2306
2307
            float f = this.rand.nextFloat() * 0.2F + 0.1F;
2308
2309
            if (i == 0)
2310
            {
2311
                this.motionX = (double)(-f);
2312
            }
2313
2314
            if (i == 1)
2315
            {
2316
                this.motionX = (double)f;
2317
            }
2318
2319
            if (i == 3)
2320
            {
2321
                this.motionY = (double)f;
2322
            }
2323
2324
            if (i == 4)
2325
            {
2326
                this.motionZ = (double)(-f);
2327
            }
2328
2329
            if (i == 5)
2330
            {
2331
                this.motionZ = (double)f;
2332
            }
2333
2334
            return true;
2335
        }
2336
    }
2337
2338
    /**
2339
     * Sets the Entity inside a web block.
2340
     */
2341
    public void setInWeb()
2342
    {
2343
        this.isInWeb = true;
2344
        this.fallDistance = 0.0F;
2345
    }
2346
2347
    /**
2348
     * Get the name of this object. For players this returns their username
2349
     */
2350
    public String getName()
2351
    {
2352
        if (this.hasCustomName())
2353
        {
2354
            return this.getCustomNameTag();
2355
        }
2356
        else
2357
        {
2358
            String s = EntityList.getEntityString(this);
2359
2360
            if (s == null)
2361
            {
2362
                s = "generic";
2363
            }
2364
2365
            return StatCollector.translateToLocal("entity." + s + ".name");
2366
        }
2367
    }
2368
2369
    /**
2370
     * Return the Entity parts making up this Entity (currently only for dragons)
2371
     */
2372
    public Entity[] getParts()
2373
    {
2374
        return null;
2375
    }
2376
2377
    /**
2378
     * Returns true if Entity argument is equal to this Entity
2379
     */
2380
    public boolean isEntityEqual(Entity entityIn)
2381
    {
2382
        return this == entityIn;
2383
    }
2384
2385
    public float getRotationYawHead()
2386
    {
2387
        return 0.0F;
2388
    }
2389
2390
    /**
2391
     * Sets the head's yaw rotation of the entity.
2392
     */
2393
    public void setRotationYawHead(float rotation)
2394
    {
2395
    }
2396
2397
    /**
2398
     * Set the render yaw offset
2399
     *  
2400
     * @param offset The render yaw offset
2401
     */
2402
    public void setRenderYawOffset(float offset)
2403
    {
2404
    }
2405
2406
    /**
2407
     * If returns false, the item will not inflict any damage against entities.
2408
     */
2409
    public boolean canAttackWithItem()
2410
    {
2411
        return true;
2412
    }
2413
2414
    /**
2415
     * Called when a player attacks an entity. If this returns true the attack will not happen.
2416
     */
2417
    public boolean hitByEntity(Entity entityIn)
2418
    {
2419
        return false;
2420
    }
2421
2422
    public String toString()
2423
    {
2424
        return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] {this.getClass().getSimpleName(), this.getName(), Integer.valueOf(this.entityId), this.worldObj == null ? "~NULL~" : this.worldObj.getWorldInfo().getWorldName(), Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)});
2425
    }
2426
2427
    public boolean isEntityInvulnerable(DamageSource source)
2428
    {
2429
        return this.invulnerable && source != DamageSource.outOfWorld && !source.isCreativePlayer();
2430
    }
2431
2432
    /**
2433
     * Sets this entity's location and angles to the location and angles of the passed in entity.
2434
     */
2435
    public void copyLocationAndAnglesFrom(Entity entityIn)
2436
    {
2437
        this.setLocationAndAngles(entityIn.posX, entityIn.posY, entityIn.posZ, entityIn.rotationYaw, entityIn.rotationPitch);
2438
    }
2439
2440
    /**
2441
     * Prepares this entity in new dimension by copying NBT data from entity in old dimension
2442
     */
2443
    public void copyDataFromOld(Entity entityIn)
2444
    {
2445
        NBTTagCompound nbttagcompound = new NBTTagCompound();
2446
        entityIn.writeToNBT(nbttagcompound);
2447
        this.readFromNBT(nbttagcompound);
2448
        this.timeUntilPortal = entityIn.timeUntilPortal;
2449
        this.lastPortalPos = entityIn.lastPortalPos;
2450
        this.lastPortalVec = entityIn.lastPortalVec;
2451
        this.teleportDirection = entityIn.teleportDirection;
2452
    }
2453
2454
    /**
2455
     * Teleports the entity to another dimension. Params: Dimension number to teleport to
2456
     */
2457
    public void travelToDimension(int dimensionId)
2458
    {
2459
        if (!this.worldObj.isRemote && !this.isDead)
2460
        {
2461
            this.worldObj.theProfiler.startSection("changeDimension");
2462
            MinecraftServer minecraftserver = MinecraftServer.getServer();
2463
            int i = this.dimension;
2464
            WorldServer worldserver = minecraftserver.worldServerForDimension(i);
2465
            WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId);
2466
            this.dimension = dimensionId;
2467
2468
            if (i == 1 && dimensionId == 1)
2469
            {
2470
                worldserver1 = minecraftserver.worldServerForDimension(0);
2471
                this.dimension = 0;
2472
            }
2473
2474
            this.worldObj.removeEntity(this);
2475
            this.isDead = false;
2476
            this.worldObj.theProfiler.startSection("reposition");
2477
            minecraftserver.getConfigurationManager().transferEntityToWorld(this, i, worldserver, worldserver1);
2478
            this.worldObj.theProfiler.endStartSection("reloading");
2479
            Entity entity = EntityList.createEntityByName(EntityList.getEntityString(this), worldserver1);
2480
2481
            if (entity != null)
2482
            {
2483
                entity.copyDataFromOld(this);
2484
2485
                if (i == 1 && dimensionId == 1)
2486
                {
2487
                    BlockPos blockpos = this.worldObj.getTopSolidOrLiquidBlock(worldserver1.getSpawnPoint());
2488
                    entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw, entity.rotationPitch);
2489
                }
2490
2491
                worldserver1.spawnEntityInWorld(entity);
2492
            }
2493
2494
            this.isDead = true;
2495
            this.worldObj.theProfiler.endSection();
2496
            worldserver.resetUpdateEntityTick();
2497
            worldserver1.resetUpdateEntityTick();
2498
            this.worldObj.theProfiler.endSection();
2499
        }
2500
    }
2501
2502
    /**
2503
     * Explosion resistance of a block relative to this entity
2504
     */
2505
    public float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, IBlockState blockStateIn)
2506
    {
2507
        return blockStateIn.getBlock().getExplosionResistance(this);
2508
    }
2509
2510
    public boolean verifyExplosion(Explosion explosionIn, World worldIn, BlockPos pos, IBlockState blockStateIn, float p_174816_5_)
2511
    {
2512
        return true;
2513
    }
2514
2515
    /**
2516
     * The maximum height from where the entity is alowed to jump (used in pathfinder)
2517
     */
2518
    public int getMaxFallHeight()
2519
    {
2520
        return 3;
2521
    }
2522
2523
    public Vec3 func_181014_aG()
2524
    {
2525
        return this.lastPortalVec;
2526
    }
2527
2528
    public EnumFacing getTeleportDirection()
2529
    {
2530
        return this.teleportDirection;
2531
    }
2532
2533
    /**
2534
     * Return whether this entity should NOT trigger a pressure plate or a tripwire.
2535
     */
2536
    public boolean doesEntityNotTriggerPressurePlate()
2537
    {
2538
        return false;
2539
    }
2540
2541
    public void addEntityCrashInfo(CrashReportCategory category)
2542
    {
2543
        category.addCrashSectionCallable("Entity Type", new Callable<String>()
2544
        {
2545
            public String call() throws Exception
2546
            {
2547
                return EntityList.getEntityString(Entity.this) + " (" + Entity.this.getClass().getCanonicalName() + ")";
2548
            }
2549
        });
2550
        category.addCrashSection("Entity ID", Integer.valueOf(this.entityId));
2551
        category.addCrashSectionCallable("Entity Name", new Callable<String>()
2552
        {
2553
            public String call() throws Exception
2554
            {
2555
                return Entity.this.getName();
2556
            }
2557
        });
2558
        category.addCrashSection("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)}));
2559
        category.addCrashSection("Entity\'s Block location", CrashReportCategory.getCoordinateInfo((double)MathHelper.floor_double(this.posX), (double)MathHelper.floor_double(this.posY), (double)MathHelper.floor_double(this.posZ)));
2560
        category.addCrashSection("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ)}));
2561
        category.addCrashSectionCallable("Entity\'s Rider", new Callable<String>()
2562
        {
2563
            public String call() throws Exception
2564
            {
2565
                return Entity.this.riddenByEntity.toString();
2566
            }
2567
        });
2568
        category.addCrashSectionCallable("Entity\'s Vehicle", new Callable<String>()
2569
        {
2570
            public String call() throws Exception
2571
            {
2572
                return Entity.this.ridingEntity.toString();
2573
            }
2574
        });
2575
    }
2576
2577
    /**
2578
     * Return whether this entity should be rendered as on fire.
2579
     */
2580
    public boolean canRenderOnFire()
2581
    {
2582
        return this.isBurning();
2583
    }
2584
2585
    public UUID getUniqueID()
2586
    {
2587
        return this.entityUniqueID;
2588
    }
2589
2590
    public boolean isPushedByWater()
2591
    {
2592
        return true;
2593
    }
2594
2595
    /**
2596
     * Get the formatted ChatComponent that will be used for the sender's username in chat
2597
     */
2598
    public IChatComponent getDisplayName()
2599
    {
2600
        ChatComponentText chatcomponenttext = new ChatComponentText(this.getName());
2601
        chatcomponenttext.getChatStyle().setChatHoverEvent(this.getHoverEvent());
2602
        chatcomponenttext.getChatStyle().setInsertion(this.getUniqueID().toString());
2603
        return chatcomponenttext;
2604
    }
2605
2606
    /**
2607
     * Sets the custom name tag for this entity
2608
     */
2609
    public void setCustomNameTag(String name)
2610
    {
2611
        this.dataWatcher.updateObject(2, name);
2612
    }
2613
2614
    public String getCustomNameTag()
2615
    {
2616
        return this.dataWatcher.getWatchableObjectString(2);
2617
    }
2618
2619
    /**
2620
     * Returns true if this thing is named
2621
     */
2622
    public boolean hasCustomName()
2623
    {
2624
        return this.dataWatcher.getWatchableObjectString(2).length() > 0;
2625
    }
2626
2627
    public void setAlwaysRenderNameTag(boolean alwaysRenderNameTag)
2628
    {
2629
        this.dataWatcher.updateObject(3, Byte.valueOf((byte)(alwaysRenderNameTag ? 1 : 0)));
2630
    }
2631
2632
    public boolean getAlwaysRenderNameTag()
2633
    {
2634
        return this.dataWatcher.getWatchableObjectByte(3) == 1;
2635
    }
2636
2637
    /**
2638
     * Sets the position of the entity and updates the 'last' variables
2639
     */
2640
    public void setPositionAndUpdate(double x, double y, double z)
2641
    {
2642
        this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
2643
    }
2644
2645
    public boolean getAlwaysRenderNameTagForRender()
2646
    {
2647
        return this.getAlwaysRenderNameTag();
2648
    }
2649
2650
    public void onDataWatcherUpdate(int dataID)
2651
    {
2652
    }
2653
2654
    public EnumFacing getHorizontalFacing()
2655
    {
2656
        return EnumFacing.getHorizontal(MathHelper.floor_double((double)(this.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3);
2657
    }
2658
2659
    protected HoverEvent getHoverEvent()
2660
    {
2661
        NBTTagCompound nbttagcompound = new NBTTagCompound();
2662
        String s = EntityList.getEntityString(this);
2663
        nbttagcompound.setString("id", this.getUniqueID().toString());
2664
2665
        if (s != null)
2666
        {
2667
            nbttagcompound.setString("type", s);
2668
        }
2669
2670
        nbttagcompound.setString("name", this.getName());
2671
        return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new ChatComponentText(nbttagcompound.toString()));
2672
    }
2673
2674
    public boolean isSpectatedByPlayer(EntityPlayerMP player)
2675
    {
2676
        return true;
2677
    }
2678
2679
    public AxisAlignedBB getEntityBoundingBox()
2680
    {
2681
        return this.boundingBox;
2682
    }
2683
2684
    public void setEntityBoundingBox(AxisAlignedBB bb)
2685
    {
2686
        this.boundingBox = bb;
2687
    }
2688
2689
    public float getEyeHeight()
2690
    {
2691
        return this.height * 0.85F;
2692
    }
2693
2694
    public boolean isOutsideBorder()
2695
    {
2696
        return this.isOutsideBorder;
2697
    }
2698
2699
    public void setOutsideBorder(boolean outsideBorder)
2700
    {
2701
        this.isOutsideBorder = outsideBorder;
2702
    }
2703
2704
    public boolean replaceItemInInventory(int inventorySlot, ItemStack itemStackIn)
2705
    {
2706
        return false;
2707
    }
2708
2709
    /**
2710
     * Send a chat message to the CommandSender
2711
     */
2712
    public void addChatMessage(IChatComponent component)
2713
    {
2714
    }
2715
2716
    /**
2717
     * Returns {@code true} if the CommandSender is allowed to execute the command, {@code false} if not
2718
     */
2719
    public boolean canCommandSenderUseCommand(int permLevel, String commandName)
2720
    {
2721
        return true;
2722
    }
2723
2724
    /**
2725
     * Get the position in the world. <b>{@code null} is not allowed!</b> If you are not an entity in the world, return
2726
     * the coordinates 0, 0, 0
2727
     */
2728
    public BlockPos getPosition()
2729
    {
2730
        return new BlockPos(this.posX, this.posY + 0.5D, this.posZ);
2731
    }
2732
2733
    /**
2734
     * Get the position vector. <b>{@code null} is not allowed!</b> If you are not an entity in the world, return 0.0D,
2735
     * 0.0D, 0.0D
2736
     */
2737
    public Vec3 getPositionVector()
2738
    {
2739
        return new Vec3(this.posX, this.posY, this.posZ);
2740
    }
2741
2742
    /**
2743
     * Get the world, if available. <b>{@code null} is not allowed!</b> If you are not an entity in the world, return
2744
     * the overworld
2745
     */
2746
    public World getEntityWorld()
2747
    {
2748
        return this.worldObj;
2749
    }
2750
2751
    /**
2752
     * Returns the entity associated with the command sender. MAY BE NULL!
2753
     */
2754
    public Entity getCommandSenderEntity()
2755
    {
2756
        return this;
2757
    }
2758
2759
    /**
2760
     * Returns true if the command sender should be sent feedback about executed commands
2761
     */
2762
    public boolean sendCommandFeedback()
2763
    {
2764
        return false;
2765
    }
2766
2767
    public void setCommandStat(CommandResultStats.Type type, int amount)
2768
    {
2769
        this.cmdResultStats.setCommandStatScore(this, type, amount);
2770
    }
2771
2772
    public CommandResultStats getCommandStats()
2773
    {
2774
        return this.cmdResultStats;
2775
    }
2776
2777
    /**
2778
     * Set the CommandResultStats from the entity
2779
     */
2780
    public void setCommandStats(Entity entityIn)
2781
    {
2782
        this.cmdResultStats.addAllStats(entityIn.getCommandStats());
2783
    }
2784
2785
    public NBTTagCompound getNBTTagCompound()
2786
    {
2787
        return null;
2788
    }
2789
2790
    /**
2791
     * Called when client receives entity's NBTTagCompound from server.
2792
     */
2793
    public void clientUpdateEntityNBT(NBTTagCompound compound)
2794
    {
2795
    }
2796
2797
    /**
2798
     * New version of interactWith that includes vector information on where precisely the player targeted.
2799
     */
2800
    public boolean interactAt(EntityPlayer player, Vec3 targetVec3)
2801
    {
2802
        return false;
2803
    }
2804
2805
    public boolean isImmuneToExplosions()
2806
    {
2807
        return false;
2808
    }
2809
2810
    protected void applyEnchantments(EntityLivingBase entityLivingBaseIn, Entity entityIn)
2811
    {
2812
        if (entityIn instanceof EntityLivingBase)
2813
        {
2814
            EnchantmentHelper.applyThornEnchantments((EntityLivingBase)entityIn, entityLivingBaseIn);
2815
        }
2816
2817
        EnchantmentHelper.applyArthropodEnchantments(entityLivingBaseIn, entityIn);
2818
    }
2819
}
2820

Deobfuscated MCP 1.8.9 source of Entity from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/Entity.java), stored verbatim.