2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityZombie.java
|
|
|
|
+++ b/net/minecraft/server/EntityZombie.java
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -9,6 +9,15 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
import java.util.function.Predicate;
|
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;
|
2019-07-26 01:58:18 +02:00
|
|
|
+import org.bukkit.entity.Zombie;
|
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 {
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
|
2019-07-26 01:58:18 +02:00
|
|
|
@@ -23,6 +32,7 @@
|
2020-08-11 23:00:00 +02:00
|
|
|
private boolean bs;
|
|
|
|
private int bt;
|
2018-12-25 22:00:00 +01:00
|
|
|
public int drownedConversionTime;
|
2018-11-06 08:03:42 +01:00
|
|
|
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
|
2018-11-06 08:03:42 +01:00
|
|
|
super(entitytypes, world);
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -139,7 +149,10 @@
|
2018-11-06 08:03:42 +01:00
|
|
|
public void tick() {
|
2020-06-25 02:00:00 +02:00
|
|
|
if (!this.world.isClientSide && this.isAlive() && !this.isNoAI()) {
|
2019-04-23 04:00:00 +02:00
|
|
|
if (this.isDrownConverting()) {
|
2018-12-06 00:00:00 +01:00
|
|
|
- --this.drownedConversionTime;
|
2019-04-23 04:00:00 +02:00
|
|
|
+ // CraftBukkit start - Use wall time instead of ticks for conversion
|
2018-11-06 08:03:42 +01:00
|
|
|
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
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) {
|
2020-08-11 23:00:00 +02:00
|
|
|
this.eP();
|
2018-11-06 08:03:42 +01:00
|
|
|
}
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -156,6 +169,7 @@
|
2020-06-24 00:52:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
super.tick();
|
|
|
|
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -188,6 +202,7 @@
|
2019-06-28 09:37:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void startDrownedConversion(int i) {
|
|
|
|
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
|
|
|
this.drownedConversionTime = i;
|
|
|
|
this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true);
|
|
|
|
}
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -201,12 +216,13 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void b(EntityTypes<? extends EntityZombie> entitytypes) {
|
|
|
|
- EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true);
|
|
|
|
+ EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
|
|
|
|
|
|
|
|
if (entityzombie != null) {
|
|
|
|
entityzombie.y(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d());
|
|
|
|
entityzombie.u(entityzombie.eK() && this.eU());
|
2018-07-26 14:02:02 +02:00
|
|
|
}
|
2020-07-01 06:17:48 +02:00
|
|
|
+ else { ((Zombie) getBukkitEntity()).setConversionTime(-1); } // CraftBukkit - SPIGOT-5208: End conversion to stop event spam
|
2020-06-25 02:00:00 +02:00
|
|
|
|
2018-07-26 14:02:02 +02:00
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -245,9 +261,9 @@
|
|
|
|
if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
|
2020-08-11 23:00:00 +02:00
|
|
|
if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.j((Entity) entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- entityzombie.setGoalTarget(entityliving);
|
2018-07-15 02:00:00 +02:00
|
|
|
+ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
|
2020-08-11 23:00:00 +02:00
|
|
|
entityzombie.prepare(worldserver, this.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
|
|
|
|
- worldserver.addAllEntities(entityzombie);
|
|
|
|
+ worldserver.addAllEntities(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
2020-06-25 02:00:00 +02:00
|
|
|
this.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
|
|
|
|
entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
|
2020-08-11 23:00:00 +02:00
|
|
|
break;
|
|
|
|
@@ -268,7 +284,14 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
float f = this.world.getDamageScaler(this.getChunkCoordinates()).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
|
|
|
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -349,7 +372,12 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2020-08-11 23:00:00 +02:00
|
|
|
EntityVillager entityvillager = (EntityVillager) entityliving;
|
|
|
|
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false);
|
2018-11-14 04:10:22 +01:00
|
|
|
+ // CraftBukkit start
|
2020-08-11 23:00:00 +02:00
|
|
|
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION);
|
|
|
|
+ if (entityzombievillager == null) {
|
2018-11-14 04:10:22 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
2018-12-04 23:51:20 +01:00
|
|
|
+ // CraftBukkit end
|
2020-08-11 23:00:00 +02:00
|
|
|
|
|
|
|
entityzombievillager.prepare(worldserver, worldserver.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null);
|
|
|
|
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
|
|
|
|
@@ -406,7 +434,7 @@
|
|
|
|
entitychicken1.prepare(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
|
2020-06-25 02:00:00 +02:00
|
|
|
entitychicken1.setChickenJockey(true);
|
|
|
|
this.startRiding(entitychicken1);
|
2020-08-11 23:00:00 +02:00
|
|
|
- worldaccess.addEntity(entitychicken1);
|
|
|
|
+ worldaccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|