2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityZombie.java
+++ b/net/minecraft/server/EntityZombie.java
2019-01-09 10:38:37 +01:00
@@ -6,6 +6,14 @@
2014-11-25 22:32:16 +01:00
import java.util.UUID;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2014-11-25 22:32:16 +01:00
2018-11-06 08:03:42 +01:00
+// CraftBukkit start
2018-11-14 04:10:22 +01:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
2014-11-25 22:32:16 +01:00
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
2018-11-14 04:10:22 +01:00
+import org.bukkit.event.entity.EntityTransformEvent;
2018-11-06 08:03:42 +01:00
+// CraftBukkit end
2014-11-25 22:32:16 +01:00
+
public class EntityZombie extends EntityMonster {
2018-07-15 02:00:00 +02:00
protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
2019-01-09 10:38:37 +01:00
@@ -21,6 +29,7 @@
2018-12-25 22:00:00 +01:00
public int drownedConversionTime;
2018-11-06 08:03:42 +01:00
private float bK;
private float bL;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public EntityZombie(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
2019-01-09 10:38:37 +01:00
@@ -143,8 +152,12 @@
2018-11-06 08:03:42 +01:00
public void tick() {
if (!this.world.isClientSide) {
2018-12-06 00:00:00 +01:00
- if (this.isDrownConverting()) {
- --this.drownedConversionTime;
2018-11-06 08:03:42 +01:00
+ // CraftBukkit start - Use wall time instead of ticks for conversion
2018-12-06 00:00:00 +01:00
+ if (this.isDrownConverting() && this.isAlive()) {
2018-11-06 08:03:42 +01:00
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
2018-12-06 00:00:00 +01:00
+ this.drownedConversionTime -= elapsedTicks;
2018-11-06 08:03:42 +01:00
+ // CraftBukkit end
2018-12-06 00:00:00 +01:00
if (this.drownedConversionTime < 0) {
2018-11-06 08:03:42 +01:00
this.dE();
}
2019-01-09 10:38:37 +01:00
@@ -221,7 +234,12 @@
2018-07-26 14:02:02 +02:00
entityzombie.setCustomNameVisible(this.getCustomNameVisible());
}
- this.world.addEntity(entityzombie);
2018-11-14 04:10:22 +01:00
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombie, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
2018-07-26 14:02:02 +02:00
+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.DROWNED); // CraftBukkit - added spawn reason
this.die();
}
}
2019-01-09 10:38:37 +01:00
@@ -252,8 +270,8 @@
2017-05-19 13:00:13 +02:00
if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
2014-11-25 22:32:16 +01:00
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
2018-08-26 04:00:00 +02:00
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())) {
2014-11-25 22:32:16 +01:00
- this.world.addEntity(entityzombie);
- entityzombie.setGoalTarget(entityliving);
+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
2018-07-15 02:00:00 +02:00
+ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
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));
entityzombie.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
2019-01-09 10:38:37 +01:00
@@ -276,7 +294,14 @@
2018-07-15 02:00:00 +02:00
float f = this.world.getDamageScaler(new BlockPosition(this)).b();
2014-11-25 22:32:16 +01:00
2016-11-17 02:41:03 +01:00
if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) {
- entity.setOnFire(2 * (int) f);
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
2016-06-09 03:43:49 +02:00
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme
2014-11-25 22:32:16 +01:00
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
2019-01-11 01:41:32 +01:00
+ entity.setOnFire(event.getDuration(), false);
2014-11-25 22:32:16 +01:00
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
}
}
2014-11-25 22:32:16 +01:00
2019-01-09 10:38:37 +01:00
@@ -362,7 +387,7 @@
2018-12-04 23:51:20 +01:00
EntityZombieVillager entityzombievillager = new EntityZombieVillager(this.world);
entityzombievillager.u(entityvillager);
- this.world.kill(entityvillager);
+ // this.world.kill(entityvillager); // CraftBukkit - moved down
2018-12-25 22:00:00 +01:00
entityzombievillager.prepare(this.world.getDamageScaler(new BlockPosition(entityzombievillager)), new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null);
2018-12-04 23:51:20 +01:00
entityzombievillager.setProfession(entityvillager.getProfession());
entityzombievillager.setBaby(entityvillager.isBaby());
2019-01-09 10:38:37 +01:00
@@ -372,7 +397,13 @@
2016-11-17 02:41:03 +01:00
entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible());
2014-11-25 22:32:16 +01:00
}
2016-11-17 02:41:03 +01:00
- this.world.addEntity(entityzombievillager);
2018-11-14 04:10:22 +01:00
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ return;
+ }
2018-12-04 23:51:20 +01:00
+ this.world.kill(entityvillager); // CraftBukkit - from above
2016-11-17 02:41:03 +01:00
+ this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
2018-12-04 23:51:20 +01:00
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
2014-11-25 22:32:16 +01:00
}
2019-01-09 10:38:37 +01:00
@@ -422,7 +453,7 @@
2014-11-25 22:32:16 +01:00
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
2018-07-15 02:00:00 +02:00
entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.s(true);
2014-11-25 22:32:16 +01:00
- this.world.addEntity(entitychicken1);
2016-02-29 22:32:46 +01:00
+ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
this.startRiding(entitychicken1);
2014-11-25 22:32:16 +01:00
}
}
2019-01-09 10:38:37 +01:00
@@ -495,7 +526,7 @@
2015-04-13 12:47:47 +02:00
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // CraftBukkit
2016-11-17 02:41:03 +01:00
if (damagesource.getEntity() instanceof EntityCreeper) {
EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
2019-01-09 10:38:37 +01:00
@@ -508,6 +539,7 @@
2016-11-17 02:41:03 +01:00
}
}
2015-04-13 12:47:47 +02:00
}
+ super.die(damagesource); // CraftBukkit - moved from above
2016-03-07 09:51:42 +01:00
2015-04-13 12:47:47 +02:00
}