EntityEnderman .java

net.minecraft.entity.monster.EntityEnderman (class): members: attackingSpeedBoostModifierUUID, attackingSpeedBoostModifier, getHeldBlockState, AITakeBlock.

net.minecraft.entity.monsterclass618 linescommonextends EntityMob21.8 KB

API Surface (30)

boolean apply(EntityEndermite p_apply_1_)
void applyEntityAttributes()
void entityInit()
void writeEntityToNBT(NBTTagCompound tagCompound)
void readEntityFromNBT(NBTTagCompound tagCompund)
float getEyeHeight()
void onLivingUpdate()
void updateAITasks()
boolean teleportRandomly()
boolean teleportToEntity(Entity p_70816_1_)
boolean teleportTo(double x, double y, double z)
String getLivingSound()
String getHurtSound()
String getDeathSound()
Item getDropItem()
void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
void setHeldBlockState(IBlockState state)
IBlockState getHeldBlockState()
boolean attackEntityFrom(DamageSource source, float amount)
boolean isScreaming()
void setScreaming(boolean screaming)
boolean shouldExecute()
void startExecuting()
void resetTask()
boolean continueExecuting()
void updateTask()
boolean shouldExecute()
void updateTask()
boolean shouldExecute()
void updateTask()

Fields & Constants (4)

attackingSpeedBoostModifierUUID
attackingSpeedBoostModifier
carriableBlocks
isAggressive

String literals (11)

"020E0DFB-87AE-4653-9556-831010E291A0"
"Attacking speed boost"
"carried"
"carriedData"
"mob.endermen.portal"
"mob.endermen.scream"
"mob.endermen.idle"
"mob.endermen.hit"
"mob.endermen.death"
"mob.endermen.stare"
"mobGriefing"

Full Source

EntityEnderman.java618 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.monster;
2
3
import com.google.common.base.Predicate;
4
import com.google.common.collect.Sets;
5
import java.util.Collections;
6
import java.util.List;
7
import java.util.Random;
8
import java.util.Set;
9
import java.util.UUID;
10
import net.minecraft.block.Block;
11
import net.minecraft.block.material.Material;
12
import net.minecraft.block.state.IBlockState;
13
import net.minecraft.entity.Entity;
14
import net.minecraft.entity.EntityLivingBase;
15
import net.minecraft.entity.SharedMonsterAttributes;
16
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
17
import net.minecraft.entity.ai.EntityAIBase;
18
import net.minecraft.entity.ai.EntityAIHurtByTarget;
19
import net.minecraft.entity.ai.EntityAILookIdle;
20
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
21
import net.minecraft.entity.ai.EntityAISwimming;
22
import net.minecraft.entity.ai.EntityAIWander;
23
import net.minecraft.entity.ai.EntityAIWatchClosest;
24
import net.minecraft.entity.ai.attributes.AttributeModifier;
25
import net.minecraft.entity.ai.attributes.IAttributeInstance;
26
import net.minecraft.entity.player.EntityPlayer;
27
import net.minecraft.entity.player.EntityPlayerMP;
28
import net.minecraft.init.Blocks;
29
import net.minecraft.init.Items;
30
import net.minecraft.item.Item;
31
import net.minecraft.item.ItemStack;
32
import net.minecraft.nbt.NBTTagCompound;
33
import net.minecraft.util.BlockPos;
34
import net.minecraft.util.DamageSource;
35
import net.minecraft.util.EntityDamageSource;
36
import net.minecraft.util.EntityDamageSourceIndirect;
37
import net.minecraft.util.EnumParticleTypes;
38
import net.minecraft.util.MathHelper;
39
import net.minecraft.util.Vec3;
40
import net.minecraft.world.World;
41
42
public class EntityEnderman extends EntityMob
43
{
44
    private static final UUID attackingSpeedBoostModifierUUID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
45
    private static final AttributeModifier attackingSpeedBoostModifier = (new AttributeModifier(attackingSpeedBoostModifierUUID, "Attacking speed boost", 0.15000000596046448D, 0)).setSaved(false);
46
    private static final Set<Block> carriableBlocks = Sets.<Block>newIdentityHashSet();
47
    private boolean isAggressive;
48
49
    public EntityEnderman(World worldIn)
50
    {
51
        super(worldIn);
52
        this.setSize(0.6F, 2.9F);
53
        this.stepHeight = 1.0F;
54
        this.tasks.addTask(0, new EntityAISwimming(this));
55
        this.tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0D, false));
56
        this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
57
        this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
58
        this.tasks.addTask(8, new EntityAILookIdle(this));
59
        this.tasks.addTask(10, new EntityEnderman.AIPlaceBlock(this));
60
        this.tasks.addTask(11, new EntityEnderman.AITakeBlock(this));
61
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
62
        this.targetTasks.addTask(2, new EntityEnderman.AIFindPlayer(this));
63
        this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityEndermite.class, 10, true, false, new Predicate<EntityEndermite>()
64
        {
65
            public boolean apply(EntityEndermite p_apply_1_)
66
            {
67
                return p_apply_1_.isSpawnedByPlayer();
68
            }
69
        }));
70
    }
71
72
    protected void applyEntityAttributes()
73
    {
74
        super.applyEntityAttributes();
75
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D);
76
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
77
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(7.0D);
78
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(64.0D);
79
    }
80
81
    protected void entityInit()
82
    {
83
        super.entityInit();
84
        this.dataWatcher.addObject(16, new Short((short)0));
85
        this.dataWatcher.addObject(17, new Byte((byte)0));
86
        this.dataWatcher.addObject(18, new Byte((byte)0));
87
    }
88
89
    /**
90
     * (abstract) Protected helper method to write subclass entity data to NBT.
91
     */
92
    public void writeEntityToNBT(NBTTagCompound tagCompound)
93
    {
94
        super.writeEntityToNBT(tagCompound);
95
        IBlockState iblockstate = this.getHeldBlockState();
96
        tagCompound.setShort("carried", (short)Block.getIdFromBlock(iblockstate.getBlock()));
97
        tagCompound.setShort("carriedData", (short)iblockstate.getBlock().getMetaFromState(iblockstate));
98
    }
99
100
    /**
101
     * (abstract) Protected helper method to read subclass entity data from NBT.
102
     */
103
    public void readEntityFromNBT(NBTTagCompound tagCompund)
104
    {
105
        super.readEntityFromNBT(tagCompund);
106
        IBlockState iblockstate;
107
108
        if (tagCompund.hasKey("carried", 8))
109
        {
110
            iblockstate = Block.getBlockFromName(tagCompund.getString("carried")).getStateFromMeta(tagCompund.getShort("carriedData") & 65535);
111
        }
112
        else
113
        {
114
            iblockstate = Block.getBlockById(tagCompund.getShort("carried")).getStateFromMeta(tagCompund.getShort("carriedData") & 65535);
115
        }
116
117
        this.setHeldBlockState(iblockstate);
118
    }
119
120
    /**
121
     * Checks to see if this enderman should be attacking this player
122
     */
123
    private boolean shouldAttackPlayer(EntityPlayer player)
124
    {
125
        ItemStack itemstack = player.inventory.armorInventory[3];
126
127
        if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
128
        {
129
            return false;
130
        }
131
        else
132
        {
133
            Vec3 vec3 = player.getLook(1.0F).normalize();
134
            Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
135
            double d0 = vec31.lengthVector();
136
            vec31 = vec31.normalize();
137
            double d1 = vec3.dotProduct(vec31);
138
            return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
139
        }
140
    }
141
142
    public float getEyeHeight()
143
    {
144
        return 2.55F;
145
    }
146
147
    /**
148
     * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
149
     * use this to react to sunlight and start to burn.
150
     */
151
    public void onLivingUpdate()
152
    {
153
        if (this.worldObj.isRemote)
154
        {
155
            for (int i = 0; i < 2; ++i)
156
            {
157
                this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - 0.25D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D, new int[0]);
158
            }
159
        }
160
161
        this.isJumping = false;
162
        super.onLivingUpdate();
163
    }
164
165
    protected void updateAITasks()
166
    {
167
        if (this.isWet())
168
        {
169
            this.attackEntityFrom(DamageSource.drown, 1.0F);
170
        }
171
172
        if (this.isScreaming() && !this.isAggressive && this.rand.nextInt(100) == 0)
173
        {
174
            this.setScreaming(false);
175
        }
176
177
        if (this.worldObj.isDaytime())
178
        {
179
            float f = this.getBrightness(1.0F);
180
181
            if (f > 0.5F && this.worldObj.canSeeSky(new BlockPos(this)) && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F)
182
            {
183
                this.setAttackTarget((EntityLivingBase)null);
184
                this.setScreaming(false);
185
                this.isAggressive = false;
186
                this.teleportRandomly();
187
            }
188
        }
189
190
        super.updateAITasks();
191
    }
192
193
    /**
194
     * Teleport the enderman to a random nearby position
195
     */
196
    protected boolean teleportRandomly()
197
    {
198
        double d0 = this.posX + (this.rand.nextDouble() - 0.5D) * 64.0D;
199
        double d1 = this.posY + (double)(this.rand.nextInt(64) - 32);
200
        double d2 = this.posZ + (this.rand.nextDouble() - 0.5D) * 64.0D;
201
        return this.teleportTo(d0, d1, d2);
202
    }
203
204
    /**
205
     * Teleport the enderman to another entity
206
     */
207
    protected boolean teleportToEntity(Entity p_70816_1_)
208
    {
209
        Vec3 vec3 = new Vec3(this.posX - p_70816_1_.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - p_70816_1_.posY + (double)p_70816_1_.getEyeHeight(), this.posZ - p_70816_1_.posZ);
210
        vec3 = vec3.normalize();
211
        double d0 = 16.0D;
212
        double d1 = this.posX + (this.rand.nextDouble() - 0.5D) * 8.0D - vec3.xCoord * d0;
213
        double d2 = this.posY + (double)(this.rand.nextInt(16) - 8) - vec3.yCoord * d0;
214
        double d3 = this.posZ + (this.rand.nextDouble() - 0.5D) * 8.0D - vec3.zCoord * d0;
215
        return this.teleportTo(d1, d2, d3);
216
    }
217
218
    /**
219
     * Teleport the enderman
220
     */
221
    protected boolean teleportTo(double x, double y, double z)
222
    {
223
        double d0 = this.posX;
224
        double d1 = this.posY;
225
        double d2 = this.posZ;
226
        this.posX = x;
227
        this.posY = y;
228
        this.posZ = z;
229
        boolean flag = false;
230
        BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
231
232
        if (this.worldObj.isBlockLoaded(blockpos))
233
        {
234
            boolean flag1 = false;
235
236
            while (!flag1 && blockpos.getY() > 0)
237
            {
238
                BlockPos blockpos1 = blockpos.down();
239
                Block block = this.worldObj.getBlockState(blockpos1).getBlock();
240
241
                if (block.getMaterial().blocksMovement())
242
                {
243
                    flag1 = true;
244
                }
245
                else
246
                {
247
                    --this.posY;
248
                    blockpos = blockpos1;
249
                }
250
            }
251
252
            if (flag1)
253
            {
254
                super.setPositionAndUpdate(this.posX, this.posY, this.posZ);
255
256
                if (this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(this.getEntityBoundingBox()))
257
                {
258
                    flag = true;
259
                }
260
            }
261
        }
262
263
        if (!flag)
264
        {
265
            this.setPosition(d0, d1, d2);
266
            return false;
267
        }
268
        else
269
        {
270
            int i = 128;
271
272
            for (int j = 0; j < i; ++j)
273
            {
274
                double d6 = (double)j / ((double)i - 1.0D);
275
                float f = (this.rand.nextFloat() - 0.5F) * 0.2F;
276
                float f1 = (this.rand.nextFloat() - 0.5F) * 0.2F;
277
                float f2 = (this.rand.nextFloat() - 0.5F) * 0.2F;
278
                double d3 = d0 + (this.posX - d0) * d6 + (this.rand.nextDouble() - 0.5D) * (double)this.width * 2.0D;
279
                double d4 = d1 + (this.posY - d1) * d6 + this.rand.nextDouble() * (double)this.height;
280
                double d5 = d2 + (this.posZ - d2) * d6 + (this.rand.nextDouble() - 0.5D) * (double)this.width * 2.0D;
281
                this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]);
282
            }
283
284
            this.worldObj.playSoundEffect(d0, d1, d2, "mob.endermen.portal", 1.0F, 1.0F);
285
            this.playSound("mob.endermen.portal", 1.0F, 1.0F);
286
            return true;
287
        }
288
    }
289
290
    /**
291
     * Returns the sound this mob makes while it's alive.
292
     */
293
    protected String getLivingSound()
294
    {
295
        return this.isScreaming() ? "mob.endermen.scream" : "mob.endermen.idle";
296
    }
297
298
    /**
299
     * Returns the sound this mob makes when it is hurt.
300
     */
301
    protected String getHurtSound()
302
    {
303
        return "mob.endermen.hit";
304
    }
305
306
    /**
307
     * Returns the sound this mob makes on death.
308
     */
309
    protected String getDeathSound()
310
    {
311
        return "mob.endermen.death";
312
    }
313
314
    protected Item getDropItem()
315
    {
316
        return Items.ender_pearl;
317
    }
318
319
    /**
320
     * Drop 0-2 items of this living's type
321
     *  
322
     * @param wasRecentlyHit true if this this entity was recently hit by appropriate entity (generally only if player
323
     * or tameable)
324
     * @param lootingModifier level of enchanment to be applied to this drop
325
     */
326
    protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
327
    {
328
        Item item = this.getDropItem();
329
330
        if (item != null)
331
        {
332
            int i = this.rand.nextInt(2 + lootingModifier);
333
334
            for (int j = 0; j < i; ++j)
335
            {
336
                this.dropItem(item, 1);
337
            }
338
        }
339
    }
340
341
    /**
342
     * Sets this enderman's held block state
343
     */
344
    public void setHeldBlockState(IBlockState state)
345
    {
346
        this.dataWatcher.updateObject(16, Short.valueOf((short)(Block.getStateId(state) & 65535)));
347
    }
348
349
    /**
350
     * Gets this enderman's held block state
351
     */
352
    public IBlockState getHeldBlockState()
353
    {
354
        return Block.getStateById(this.dataWatcher.getWatchableObjectShort(16) & 65535);
355
    }
356
357
    /**
358
     * Called when the entity is attacked.
359
     */
360
    public boolean attackEntityFrom(DamageSource source, float amount)
361
    {
362
        if (this.isEntityInvulnerable(source))
363
        {
364
            return false;
365
        }
366
        else
367
        {
368
            if (source.getEntity() == null || !(source.getEntity() instanceof EntityEndermite))
369
            {
370
                if (!this.worldObj.isRemote)
371
                {
372
                    this.setScreaming(true);
373
                }
374
375
                if (source instanceof EntityDamageSource && source.getEntity() instanceof EntityPlayer)
376
                {
377
                    if (source.getEntity() instanceof EntityPlayerMP && ((EntityPlayerMP)source.getEntity()).theItemInWorldManager.isCreative())
378
                    {
379
                        this.setScreaming(false);
380
                    }
381
                    else
382
                    {
383
                        this.isAggressive = true;
384
                    }
385
                }
386
387
                if (source instanceof EntityDamageSourceIndirect)
388
                {
389
                    this.isAggressive = false;
390
391
                    for (int i = 0; i < 64; ++i)
392
                    {
393
                        if (this.teleportRandomly())
394
                        {
395
                            return true;
396
                        }
397
                    }
398
399
                    return false;
400
                }
401
            }
402
403
            boolean flag = super.attackEntityFrom(source, amount);
404
405
            if (source.isUnblockable() && this.rand.nextInt(10) != 0)
406
            {
407
                this.teleportRandomly();
408
            }
409
410
            return flag;
411
        }
412
    }
413
414
    public boolean isScreaming()
415
    {
416
        return this.dataWatcher.getWatchableObjectByte(18) > 0;
417
    }
418
419
    public void setScreaming(boolean screaming)
420
    {
421
        this.dataWatcher.updateObject(18, Byte.valueOf((byte)(screaming ? 1 : 0)));
422
    }
423
424
    static
425
    {
426
        carriableBlocks.add(Blocks.grass);
427
        carriableBlocks.add(Blocks.dirt);
428
        carriableBlocks.add(Blocks.sand);
429
        carriableBlocks.add(Blocks.gravel);
430
        carriableBlocks.add(Blocks.yellow_flower);
431
        carriableBlocks.add(Blocks.red_flower);
432
        carriableBlocks.add(Blocks.brown_mushroom);
433
        carriableBlocks.add(Blocks.red_mushroom);
434
        carriableBlocks.add(Blocks.tnt);
435
        carriableBlocks.add(Blocks.cactus);
436
        carriableBlocks.add(Blocks.clay);
437
        carriableBlocks.add(Blocks.pumpkin);
438
        carriableBlocks.add(Blocks.melon_block);
439
        carriableBlocks.add(Blocks.mycelium);
440
    }
441
442
    static class AIFindPlayer extends EntityAINearestAttackableTarget
443
    {
444
        private EntityPlayer player;
445
        private int field_179450_h;
446
        private int field_179451_i;
447
        private EntityEnderman enderman;
448
449
        public AIFindPlayer(EntityEnderman p_i45842_1_)
450
        {
451
            super(p_i45842_1_, EntityPlayer.class, true);
452
            this.enderman = p_i45842_1_;
453
        }
454
455
        public boolean shouldExecute()
456
        {
457
            double d0 = this.getTargetDistance();
458
            List<EntityPlayer> list = this.taskOwner.worldObj.<EntityPlayer>getEntitiesWithinAABB(EntityPlayer.class, this.taskOwner.getEntityBoundingBox().expand(d0, 4.0D, d0), this.targetEntitySelector);
459
            Collections.sort(list, this.theNearestAttackableTargetSorter);
460
461
            if (list.isEmpty())
462
            {
463
                return false;
464
            }
465
            else
466
            {
467
                this.player = (EntityPlayer)list.get(0);
468
                return true;
469
            }
470
        }
471
472
        public void startExecuting()
473
        {
474
            this.field_179450_h = 5;
475
            this.field_179451_i = 0;
476
        }
477
478
        public void resetTask()
479
        {
480
            this.player = null;
481
            this.enderman.setScreaming(false);
482
            IAttributeInstance iattributeinstance = this.enderman.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
483
            iattributeinstance.removeModifier(EntityEnderman.attackingSpeedBoostModifier);
484
            super.resetTask();
485
        }
486
487
        public boolean continueExecuting()
488
        {
489
            if (this.player != null)
490
            {
491
                if (!this.enderman.shouldAttackPlayer(this.player))
492
                {
493
                    return false;
494
                }
495
                else
496
                {
497
                    this.enderman.isAggressive = true;
498
                    this.enderman.faceEntity(this.player, 10.0F, 10.0F);
499
                    return true;
500
                }
501
            }
502
            else
503
            {
504
                return super.continueExecuting();
505
            }
506
        }
507
508
        public void updateTask()
509
        {
510
            if (this.player != null)
511
            {
512
                if (--this.field_179450_h <= 0)
513
                {
514
                    this.targetEntity = this.player;
515
                    this.player = null;
516
                    super.startExecuting();
517
                    this.enderman.playSound("mob.endermen.stare", 1.0F, 1.0F);
518
                    this.enderman.setScreaming(true);
519
                    IAttributeInstance iattributeinstance = this.enderman.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
520
                    iattributeinstance.applyModifier(EntityEnderman.attackingSpeedBoostModifier);
521
                }
522
            }
523
            else
524
            {
525
                if (this.targetEntity != null)
526
                {
527
                    if (this.targetEntity instanceof EntityPlayer && this.enderman.shouldAttackPlayer((EntityPlayer)this.targetEntity))
528
                    {
529
                        if (this.targetEntity.getDistanceSqToEntity(this.enderman) < 16.0D)
530
                        {
531
                            this.enderman.teleportRandomly();
532
                        }
533
534
                        this.field_179451_i = 0;
535
                    }
536
                    else if (this.targetEntity.getDistanceSqToEntity(this.enderman) > 256.0D && this.field_179451_i++ >= 30 && this.enderman.teleportToEntity(this.targetEntity))
537
                    {
538
                        this.field_179451_i = 0;
539
                    }
540
                }
541
542
                super.updateTask();
543
            }
544
        }
545
    }
546
547
    static class AIPlaceBlock extends EntityAIBase
548
    {
549
        private EntityEnderman enderman;
550
551
        public AIPlaceBlock(EntityEnderman p_i45843_1_)
552
        {
553
            this.enderman = p_i45843_1_;
554
        }
555
556
        public boolean shouldExecute()
557
        {
558
            return !this.enderman.worldObj.getGameRules().getBoolean("mobGriefing") ? false : (this.enderman.getHeldBlockState().getBlock().getMaterial() == Material.air ? false : this.enderman.getRNG().nextInt(2000) == 0);
559
        }
560
561
        public void updateTask()
562
        {
563
            Random random = this.enderman.getRNG();
564
            World world = this.enderman.worldObj;
565
            int i = MathHelper.floor_double(this.enderman.posX - 1.0D + random.nextDouble() * 2.0D);
566
            int j = MathHelper.floor_double(this.enderman.posY + random.nextDouble() * 2.0D);
567
            int k = MathHelper.floor_double(this.enderman.posZ - 1.0D + random.nextDouble() * 2.0D);
568
            BlockPos blockpos = new BlockPos(i, j, k);
569
            Block block = world.getBlockState(blockpos).getBlock();
570
            Block block1 = world.getBlockState(blockpos.down()).getBlock();
571
572
            if (this.func_179474_a(world, blockpos, this.enderman.getHeldBlockState().getBlock(), block, block1))
573
            {
574
                world.setBlockState(blockpos, this.enderman.getHeldBlockState(), 3);
575
                this.enderman.setHeldBlockState(Blocks.air.getDefaultState());
576
            }
577
        }
578
579
        private boolean func_179474_a(World worldIn, BlockPos p_179474_2_, Block p_179474_3_, Block p_179474_4_, Block p_179474_5_)
580
        {
581
            return !p_179474_3_.canPlaceBlockAt(worldIn, p_179474_2_) ? false : (p_179474_4_.getMaterial() != Material.air ? false : (p_179474_5_.getMaterial() == Material.air ? false : p_179474_5_.isFullCube()));
582
        }
583
    }
584
585
    static class AITakeBlock extends EntityAIBase
586
    {
587
        private EntityEnderman enderman;
588
589
        public AITakeBlock(EntityEnderman p_i45841_1_)
590
        {
591
            this.enderman = p_i45841_1_;
592
        }
593
594
        public boolean shouldExecute()
595
        {
596
            return !this.enderman.worldObj.getGameRules().getBoolean("mobGriefing") ? false : (this.enderman.getHeldBlockState().getBlock().getMaterial() != Material.air ? false : this.enderman.getRNG().nextInt(20) == 0);
597
        }
598
599
        public void updateTask()
600
        {
601
            Random random = this.enderman.getRNG();
602
            World world = this.enderman.worldObj;
603
            int i = MathHelper.floor_double(this.enderman.posX - 2.0D + random.nextDouble() * 4.0D);
604
            int j = MathHelper.floor_double(this.enderman.posY + random.nextDouble() * 3.0D);
605
            int k = MathHelper.floor_double(this.enderman.posZ - 2.0D + random.nextDouble() * 4.0D);
606
            BlockPos blockpos = new BlockPos(i, j, k);
607
            IBlockState iblockstate = world.getBlockState(blockpos);
608
            Block block = iblockstate.getBlock();
609
610
            if (EntityEnderman.carriableBlocks.contains(block))
611
            {
612
                this.enderman.setHeldBlockState(iblockstate);
613
                world.setBlockState(blockpos, Blocks.air.getDefaultState());
614
            }
615
        }
616
    }
617
}
618

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