Skip to content

Commit 4bd9faf

Browse files
Partially cleanup entity hunks
1 parent 9116e29 commit 4bd9faf

File tree

55 files changed

+505
-17567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+505
-17567
lines changed

patches/minecraft/net/minecraft/entity/ai/EntityAIAttackMelee.java.patch

Lines changed: 7 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@
99

1010
public EntityAIAttackMelee(EntityCreature creature, double speedIn, boolean useLongMemory)
1111
{
12-
@@ -31,7 +33,6 @@
13-
this.setMutexBits(3);
14-
}
15-
16-
- @Override
17-
public boolean shouldExecute()
18-
{
19-
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
20-
@@ -46,16 +47,32 @@
12+
@@ -46,6 +48,19 @@
2113
}
2214
else
2315
{
@@ -35,92 +27,13 @@
3527
+ }
3628
+ }
3729
this.path = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
38-
- return this.path != null
39-
- ? true
40-
- : this.getAttackReachSqr(entitylivingbase)
41-
- >= this.attacker
42-
- .getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
43-
+
44-
+ if (this.path != null)
45-
+ {
46-
+ return true;
47-
+ }
48-
+ else
49-
+ {
50-
+ return this.getAttackReachSqr(entitylivingbase) >= this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
51-
+ }
52-
}
53-
}
54-
55-
- @Override
56-
public boolean shouldContinueExecuting()
57-
{
58-
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
59-
@@ -72,62 +89,70 @@
60-
{
61-
return !this.attacker.getNavigator().noPath();
62-
}
63-
+ else if (!this.attacker.isWithinHomeDistanceFromPosition(new BlockPos(entitylivingbase)))
64-
+ {
65-
+ return false;
66-
+ }
67-
else
68-
{
69-
- return !this.attacker.isWithinHomeDistanceFromPosition(new BlockPos(entitylivingbase))
70-
- ? false
71-
- : !(entitylivingbase instanceof EntityPlayer)
72-
- || !((EntityPlayer)entitylivingbase).isSpectator() && !((EntityPlayer)entitylivingbase).isCreative();
73-
+ return !(entitylivingbase instanceof EntityPlayer) || !((EntityPlayer)entitylivingbase).isSpectator() && !((EntityPlayer)entitylivingbase).isCreative();
74-
}
75-
}
76-
77-
- @Override
78-
public void startExecuting()
79-
{
80-
this.attacker.getNavigator().setPath(this.path, this.speedTowardsTarget);
81-
this.delayCounter = 0;
82-
}
83-
84-
- @Override
85-
public void resetTask()
86-
{
87-
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
88-
89-
if (entitylivingbase instanceof EntityPlayer && (((EntityPlayer)entitylivingbase).isSpectator() || ((EntityPlayer)entitylivingbase).isCreative()))
90-
{
91-
- this.attacker.setAttackTarget(null);
92-
+ this.attacker.setAttackTarget((EntityLivingBase)null);
93-
}
94-
95-
this.attacker.getNavigator().clearPath();
96-
}
97-
98-
- @Override
99-
public void updateTask()
100-
{
101-
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
102-
this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
103-
- double d0 = this.attacker
104-
- .getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
105-
- this.delayCounter--;
106-
+ double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
107-
+ --this.delayCounter;
108-
109-
- if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase))
110-
- && this.delayCounter <= 0
111-
- && (
112-
- this.targetX == 0.0 && this.targetY == 0.0 && this.targetZ == 0.0
113-
- || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0
114-
- || this.attacker.getRNG().nextFloat() < 0.05F
115-
- ))
116-
+ if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
117-
{
118-
this.targetX = entitylivingbase.posX;
30+
return this.path != null
31+
? true
32+
@@ -122,6 +137,23 @@
11933
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
12034
this.targetZ = entitylivingbase.posZ;
12135
this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);
122-
123-
- if (d0 > 1024.0)
36+
+
12437
+ if (this.canPenalize)
12538
+ {
12639
+ this.delayCounter += failedPathFindingPenalty;
@@ -137,13 +50,6 @@
13750
+ failedPathFindingPenalty += 10;
13851
+ }
13952
+ }
140-
+
141-
+ if (d0 > 1024.0D)
142-
{
143-
this.delayCounter += 10;
144-
}
145-
- else if (d0 > 256.0)
146-
+ else if (d0 > 256.0D)
53+
54+
if (d0 > 1024.0)
14755
{
148-
this.delayCounter += 5;
149-
}
Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,11 @@
11
--- before/net/minecraft/entity/ai/EntityAIAttackRangedBow.java
22
+++ after/net/minecraft/entity/ai/EntityAIAttackRangedBow.java
3-
@@ -33,7 +33,6 @@
4-
this.attackCooldown = p_189428_1_;
5-
}
6-
7-
- @Override
8-
public boolean shouldExecute()
9-
{
10-
return this.entity.getAttackTarget() == null ? false : this.isBowInMainhand();
11-
@@ -41,41 +40,36 @@
3+
@@ -41,7 +41,7 @@
124

135
protected boolean isBowInMainhand()
146
{
157
- return !this.entity.getHeldItemMainhand().isEmpty() && this.entity.getHeldItemMainhand().getItem() == Items.BOW;
168
+ return !this.entity.getHeldItemMainhand().isEmpty() && this.entity.getHeldItemMainhand().getItem() instanceof ItemBow;
179
}
1810

19-
- @Override
20-
public boolean shouldContinueExecuting()
21-
{
22-
return (this.shouldExecute() || !this.entity.getNavigator().noPath()) && this.isBowInMainhand();
23-
}
24-
25-
- @Override
26-
public void startExecuting()
27-
{
28-
super.startExecuting();
29-
- this.entity.setSwingingArms(true);
30-
+ ((IRangedAttackMob)this.entity).setSwingingArms(true);
31-
}
32-
33-
- @Override
34-
public void resetTask()
35-
{
36-
super.resetTask();
37-
- this.entity.setSwingingArms(false);
38-
+ ((IRangedAttackMob)this.entity).setSwingingArms(false);
39-
this.seeTime = 0;
40-
this.attackTime = -1;
41-
this.entity.resetActiveHand();
42-
}
43-
44-
- @Override
45-
public void updateTask()
46-
{
47-
EntityLivingBase entitylivingbase = this.entity.getAttackTarget();
48-
49-
if (entitylivingbase != null)
50-
{
51-
- double d0 = this.entity
52-
- .getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
53-
+ double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
54-
boolean flag = this.entity.getEntitySenses().canSee(entitylivingbase);
55-
boolean flag1 = this.seeTime > 0;
56-
57-
@@ -86,17 +80,17 @@
58-
59-
if (flag)
60-
{
61-
- this.seeTime++;
62-
+ ++this.seeTime;
63-
}
64-
else
65-
{
66-
- this.seeTime--;
67-
+ --this.seeTime;
68-
}
69-
70-
- if (!(d0 > (double)this.maxAttackDistance) && this.seeTime >= 20)
71-
+ if (d0 <= (double)this.maxAttackDistance && this.seeTime >= 20)
72-
{
73-
this.entity.getNavigator().clearPath();
74-
- this.strafingTime++;
75-
+ ++this.strafingTime;
76-
}
77-
else
78-
{
79-
@@ -106,12 +100,12 @@
80-
81-
if (this.strafingTime >= 20)
82-
{
83-
- if ((double)this.entity.getRNG().nextFloat() < 0.3)
84-
+ if ((double)this.entity.getRNG().nextFloat() < 0.3D)
85-
{
86-
this.strafingClockwise = !this.strafingClockwise;
87-
}
88-
89-
- if ((double)this.entity.getRNG().nextFloat() < 0.3)
90-
+ if ((double)this.entity.getRNG().nextFloat() < 0.3D)
91-
{
92-
this.strafingBackwards = !this.strafingBackwards;
93-
}
94-
@@ -151,7 +145,7 @@
95-
if (i >= 20)
96-
{
97-
this.entity.resetActiveHand();
98-
- this.entity.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i));
99-
+ ((IRangedAttackMob)this.entity).attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i));
100-
this.attackTime = this.attackCooldown;
101-
}
102-
}
11+
@Override
Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,25 @@
11
--- before/net/minecraft/entity/ai/EntityAIBreakDoor.java
22
+++ after/net/minecraft/entity/ai/EntityAIBreakDoor.java
3-
@@ -15,43 +15,55 @@
4-
super(entityIn);
5-
}
6-
7-
- @Override
8-
public boolean shouldExecute()
9-
{
10-
if (!super.shouldExecute())
11-
{
12-
return false;
3+
@@ -24,7 +24,21 @@
134
}
14-
+ else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.entity.world, this.entity) || !this.entity.world.getBlockState(this.doorPosition).getBlock().canEntityDestroy(this.entity.world.getBlockState(this.doorPosition), this.entity.world, this.doorPosition, this.entity) || !net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this.entity, this.doorPosition, this.entity.world.getBlockState(this.doorPosition)))
15-
+ {
16-
+ return false;
17-
+ }
185
else
196
{
207
- return !this.entity.world.getGameRules().getBoolean("mobGriefing")
21-
- ? false
22-
- : !BlockDoor.isOpen(this.entity.world, this.doorPosition);
23-
+ BlockDoor blockdoor = this.doorBlock;
24-
+ return !BlockDoor.isOpen(this.entity.world, this.doorPosition);
25-
}
26-
}
27-
28-
- @Override
29-
public void startExecuting()
30-
{
31-
super.startExecuting();
32-
this.breakingTime = 0;
33-
}
34-
35-
- @Override
36-
public boolean shouldContinueExecuting()
37-
{
38-
double d0 = this.entity.getDistanceSq(this.doorPosition);
39-
- return this.breakingTime <= 240 && !BlockDoor.isOpen(this.entity.world, this.doorPosition) && d0 < 4.0;
40-
+ boolean flag;
41-
+
42-
+ if (this.breakingTime <= 240)
43-
+ {
44-
+ BlockDoor blockdoor = this.doorBlock;
45-
+
46-
+ if (!BlockDoor.isOpen(this.entity.world, this.doorPosition) && d0 < 4.0D)
47-
+ {
48-
+ flag = true;
49-
+ return flag;
50-
+ }
51-
+ }
52-
+
53-
+ flag = false;
54-
+ return flag;
55-
}
56-
57-
- @Override
58-
public void resetTask()
59-
{
60-
super.resetTask();
61-
this.entity.world.sendBlockBreakProgress(this.entity.getEntityId(), this.doorPosition, -1);
62-
}
63-
64-
- @Override
65-
public void updateTask()
66-
{
67-
super.updateTask();
68-
@@ -61,7 +73,7 @@
69-
this.entity.world.playEvent(1019, this.doorPosition, 0);
8+
+ return !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.entity.world, this.entity)
9+
+ || !this.entity.world
10+
+ .getBlockState(this.doorPosition)
11+
+ .getBlock()
12+
+ .canEntityDestroy(
13+
+ this.entity.world.getBlockState(this.doorPosition),
14+
+ this.entity.world,
15+
+ this.doorPosition,
16+
+ this.entity
17+
+ )
18+
+ || !net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(
19+
+ this.entity,
20+
+ this.doorPosition,
21+
+ this.entity.world.getBlockState(this.doorPosition)
22+
+ )
23+
? false
24+
: !BlockDoor.isOpen(this.entity.world, this.doorPosition);
7025
}
71-
72-
- this.breakingTime++;
73-
+ ++this.breakingTime;
74-
int i = (int)((float)this.breakingTime / 240.0F * 10.0F);
75-
76-
if (i != this.previousBreakProgress)

patches/minecraft/net/minecraft/entity/ai/EntityAIEatGrass.java.patch

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,5 @@
11
--- before/net/minecraft/entity/ai/EntityAIEatGrass.java
22
+++ after/net/minecraft/entity/ai/EntityAIEatGrass.java
3-
@@ -13,8 +13,7 @@
4-
5-
public class EntityAIEatGrass extends EntityAIBase
6-
{
7-
- private static final Predicate<IBlockState> IS_TALL_GRASS = BlockStateMatcher.forBlock(Blocks.TALLGRASS)
8-
- .where(BlockTallGrass.TYPE, Predicates.equalTo(BlockTallGrass.EnumType.GRASS));
9-
+ private static final Predicate<IBlockState> IS_TALL_GRASS = BlockStateMatcher.forBlock(Blocks.TALLGRASS).where(BlockTallGrass.TYPE, Predicates.equalTo(BlockTallGrass.EnumType.GRASS));
10-
private final EntityLiving grassEaterEntity;
11-
private final World entityWorld;
12-
int eatingGrassTimer;
13-
@@ -26,7 +25,6 @@
14-
this.setMutexBits(7);
15-
}
16-
17-
- @Override
18-
public boolean shouldExecute()
19-
{
20-
if (this.grassEaterEntity.getRNG().nextInt(this.grassEaterEntity.isChild() ? 50 : 1000) != 0)
21-
@@ -36,13 +34,18 @@
22-
else
23-
{
24-
BlockPos blockpos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ);
25-
- return IS_TALL_GRASS.apply(this.entityWorld.getBlockState(blockpos))
26-
- ? true
27-
- : this.entityWorld.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS;
28-
+
29-
+ if (IS_TALL_GRASS.apply(this.entityWorld.getBlockState(blockpos)))
30-
+ {
31-
+ return true;
32-
+ }
33-
+ else
34-
+ {
35-
+ return this.entityWorld.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS;
36-
+ }
37-
}
38-
}
39-
40-
- @Override
41-
public void startExecuting()
42-
{
43-
this.eatingGrassTimer = 40;
44-
@@ -50,13 +53,11 @@
45-
this.grassEaterEntity.getNavigator().clearPath();
46-
}
47-
48-
- @Override
49-
public void resetTask()
50-
{
51-
this.eatingGrassTimer = 0;
52-
}
53-
54-
- @Override
55-
public boolean shouldContinueExecuting()
56-
{
57-
return this.eatingGrassTimer > 0;
58-
@@ -67,7 +68,6 @@
59-
return this.eatingGrassTimer;
60-
}
61-
62-
- @Override
63-
public void updateTask()
64-
{
65-
this.eatingGrassTimer = Math.max(0, this.eatingGrassTimer - 1);
663
@@ -78,7 +78,7 @@
674

685
if (IS_TALL_GRASS.apply(this.entityWorld.getBlockState(blockpos)))

0 commit comments

Comments
 (0)