SPIGOT-4471: Use wall time for zombie drowning & enhance checks

Thanks Zach Brown for outline of issue with drowned zombies.
This commit is contained in:
md_5 2018-11-06 18:03:42 +11:00
parent e693496c17
commit de547749ec
2 changed files with 38 additions and 12 deletions

View File

@ -14,7 +14,30 @@
public class EntityZombie extends EntityMonster { public class EntityZombie extends EntityMonster {
protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
@@ -182,7 +189,14 @@ @@ -21,6 +28,7 @@
private int bJ;
private float bK;
private float bL;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public EntityZombie(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
@@ -143,8 +151,12 @@
public void tick() {
if (!this.world.isClientSide) {
- if (this.dG()) {
- --this.bJ;
+ // CraftBukkit start - Use wall time instead of ticks for conversion
+ if (this.dG() && this.isAlive()) {
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+ this.bJ -= elapsedTicks;
+ // CraftBukkit end
if (this.bJ < 0) {
this.dE();
}
@@ -182,7 +194,14 @@
} }
if (flag) { if (flag) {
@ -30,7 +53,7 @@
} }
} }
@@ -221,7 +235,7 @@ @@ -221,7 +240,7 @@
entityzombie.setCustomNameVisible(this.getCustomNameVisible()); entityzombie.setCustomNameVisible(this.getCustomNameVisible());
} }
@ -39,7 +62,7 @@
this.die(); this.die();
} }
} }
@@ -252,8 +266,8 @@ @@ -252,8 +271,8 @@
if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
entityzombie.setPosition((double) i1, (double) j1, (double) k1); entityzombie.setPosition((double) i1, (double) j1, (double) k1);
if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.a_(entityzombie, entityzombie.getBoundingBox()) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.a_(entityzombie, entityzombie.getBoundingBox()) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
@ -50,7 +73,7 @@
entityzombie.prepare(this.world.getDamageScaler(new BlockPosition(entityzombie)), (GroupDataEntity) null, (NBTTagCompound) null); entityzombie.prepare(this.world.getDamageScaler(new BlockPosition(entityzombie)), (GroupDataEntity) null, (NBTTagCompound) null);
this.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); this.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
entityzombie.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); entityzombie.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
@@ -276,7 +290,14 @@ @@ -276,7 +295,14 @@
float f = this.world.getDamageScaler(new BlockPosition(this)).b(); float f = this.world.getDamageScaler(new BlockPosition(this)).b();
if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) {
@ -66,7 +89,7 @@
} }
} }
@@ -372,7 +393,7 @@ @@ -372,7 +398,7 @@
entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible()); entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible());
} }
@ -75,7 +98,7 @@
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0); this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
} }
@@ -422,7 +443,7 @@ @@ -422,7 +448,7 @@
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null); entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.s(true); entitychicken1.s(true);
@ -84,7 +107,7 @@
this.startRiding(entitychicken1); this.startRiding(entitychicken1);
} }
} }
@@ -495,7 +516,7 @@ @@ -495,7 +521,7 @@
} }
public void die(DamageSource damagesource) { public void die(DamageSource damagesource) {
@ -93,7 +116,7 @@
if (damagesource.getEntity() instanceof EntityCreeper) { if (damagesource.getEntity() instanceof EntityCreeper) {
EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
@@ -508,6 +529,7 @@ @@ -508,6 +534,7 @@
} }
} }
} }

View File

@ -8,9 +8,12 @@
public EntityZombieVillager(World world) { public EntityZombieVillager(World world) {
super(EntityTypes.ZOMBIE_VILLAGER, world); super(EntityTypes.ZOMBIE_VILLAGER, world);
@@ -56,6 +57,11 @@ @@ -54,8 +55,13 @@
}
public void tick() { public void tick() {
if (!this.world.isClientSide && this.isConverting()) { - if (!this.world.isClientSide && this.isConverting()) {
+ if (!this.world.isClientSide && this.isConverting() && this.isAlive()) { // CraftBukkit
int i = this.dK(); int i = this.dK();
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion + // CraftBukkit start - Use wall time instead of ticks for villager conversion
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + int elapsedTicks = MinecraftServer.currentTick - this.lastTick;