Paper/nms-patches/EntityZombie.patch

177 lines
8.8 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityZombie.java
+++ b/net/minecraft/server/EntityZombie.java
@@ -6,6 +6,15 @@
import java.util.UUID;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityCombustEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+// CraftBukkit end
+
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");
@@ -14,13 +23,14 @@
private static final DataWatcherObject<Boolean> bC = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i);
private static final DataWatcherObject<Integer> bD = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.b);
private static final DataWatcherObject<Boolean> bE = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i);
- private static final DataWatcherObject<Boolean> bF = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i);
+ public static final DataWatcherObject<Boolean> bF = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); // PAIL
private final PathfinderGoalBreakDoor bG;
private boolean bH;
private int bI;
- private int drownedConversionTime;
+ public int drownedConversionTime; // PAIL
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 +153,12 @@
public void tick() {
if (!this.world.isClientSide) {
2018-12-06 00:00:00 +01:00
- if (this.isDrownConverting()) {
- --this.drownedConversionTime;
+ // CraftBukkit start - Use wall time instead of ticks for conversion
2018-12-06 00:00:00 +01:00
+ if (this.isDrownConverting() && this.isAlive()) {
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
2018-12-06 00:00:00 +01:00
+ this.drownedConversionTime -= elapsedTicks;
+ // CraftBukkit end
2018-12-06 00:00:00 +01:00
if (this.drownedConversionTime < 0) {
this.dE();
}
@@ -182,14 +196,21 @@
2018-07-15 02:00:00 +02:00
}
2018-07-15 02:00:00 +02:00
if (flag) {
- this.setOnFire(8);
+ // CraftBukkit start
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
+ this.world.getServer().getPluginManager().callEvent(event);
+
2018-07-15 02:00:00 +02:00
+ if (!event.isCancelled()) {
+ this.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
}
}
2018-07-15 02:00:00 +02:00
super.movementTick();
}
- private void a(int i) {
+ public void a(int i) { // PAIL
this.drownedConversionTime = i;
this.getDataWatcher().set(EntityZombie.bF, true);
}
@@ -221,7 +242,12 @@
2018-07-26 14:02:02 +02:00
entityzombie.setCustomNameVisible(this.getCustomNameVisible());
}
- this.world.addEntity(entityzombie);
+ // 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();
}
}
@@ -252,8 +278,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) {
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())) {
- 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));
@@ -276,7 +302,14 @@
2018-07-15 02:00:00 +02:00
float f = this.world.getDamageScaler(new BlockPosition(this)).b();
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);
+ // CraftBukkit start
2016-06-09 03:43:49 +02:00
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ entity.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
}
}
2018-12-13 01:00:00 +01:00
@@ -362,8 +395,8 @@
EntityZombieVillager entityzombievillager = new EntityZombieVillager(this.world);
entityzombievillager.u(entityvillager);
- this.world.kill(entityvillager);
2018-12-13 01:00:00 +01:00
- entityzombievillager.prepare(this.world.getDamageScaler(new BlockPosition(entityzombievillager)), new EntityZombie.GroupDataZombie(false, null), (NBTTagCompound) null);
+ // this.world.kill(entityvillager); // CraftBukkit - moved down
2018-12-13 01:00:00 +01:00
+ entityzombievillager.prepare(this.world.getDamageScaler(new BlockPosition(entityzombievillager)), new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null); // CraftBukkit - decompile error
entityzombievillager.setProfession(entityvillager.getProfession());
entityzombievillager.setBaby(entityvillager.isBaby());
2018-12-13 01:00:00 +01:00
entityzombievillager.setNoAI(entityvillager.isNoAI());
@@ -372,7 +405,13 @@
2016-11-17 02:41:03 +01:00
entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible());
}
2016-11-17 02:41:03 +01:00
- this.world.addEntity(entityzombievillager);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ return;
+ }
+ 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
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
}
2018-12-13 01:00:00 +01:00
@@ -399,7 +438,7 @@
this.p(this.random.nextFloat() < 0.55F * f);
if (object == null) {
- object = new EntityZombie.GroupDataZombie(this.world.random.nextFloat() < 0.05F, null);
+ object = new EntityZombie.GroupDataZombie(this.world.random.nextFloat() < 0.05F); // CraftBukkit - decompile error
}
if (object instanceof EntityZombie.GroupDataZombie) {
@@ -422,7 +461,7 @@
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);
- this.world.addEntity(entitychicken1);
2016-02-29 22:32:46 +01:00
+ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
this.startRiding(entitychicken1);
}
}
@@ -495,7 +534,7 @@
}
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();
@@ -508,6 +547,7 @@
2016-11-17 02:41:03 +01:00
}
}
}
+ super.die(damagesource); // CraftBukkit - moved from above
2016-03-07 09:51:42 +01:00
}