2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/monster/EntityZombie.java
|
|
|
|
+++ b/net/minecraft/world/entity/monster/EntityZombie.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -64,6 +64,15 @@
|
|
|
|
import net.minecraft.world.level.block.Blocks;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-11-06 08:03:42 +01:00
|
|
|
+// CraftBukkit start
|
2021-03-15 23:00:00 +01:00
|
|
|
+import net.minecraft.server.MinecraftServer;
|
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 {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -84,6 +93,7 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
private boolean canBreakDoors;
|
|
|
|
private int inWaterTime;
|
|
|
|
public int conversionTime;
|
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);
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -200,7 +210,10 @@
|
2018-11-06 08:03:42 +01:00
|
|
|
public void tick() {
|
2023-06-07 17:30:00 +02:00
|
|
|
if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) {
|
2021-11-21 23:00:00 +01:00
|
|
|
if (this.isUnderWaterConverting()) {
|
2021-06-11 07:00:00 +02:00
|
|
|
- --this.conversionTime;
|
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;
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.conversionTime -= elapsedTicks;
|
2018-11-06 08:03:42 +01:00
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.conversionTime < 0) {
|
2021-11-21 23:00:00 +01:00
|
|
|
this.doUnderWaterConversion();
|
2018-11-06 08:03:42 +01:00
|
|
|
}
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -217,6 +230,7 @@
|
2020-06-24 00:52:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
super.tick();
|
|
|
|
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -249,6 +263,7 @@
|
2019-06-28 09:37:06 +02:00
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
public void startUnderWaterConversion(int i) {
|
2019-06-28 09:37:06 +02:00
|
|
|
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
2021-06-11 07:00:00 +02:00
|
|
|
this.conversionTime = i;
|
2021-11-21 23:00:00 +01:00
|
|
|
this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true);
|
2019-06-28 09:37:06 +02:00
|
|
|
}
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -262,11 +277,15 @@
|
2020-08-11 23:00:00 +02:00
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
protected void convertToZombieType(EntityTypes<? extends EntityZombie> entitytypes) {
|
|
|
|
- EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true);
|
|
|
|
+ EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
|
2020-08-11 23:00:00 +02:00
|
|
|
|
|
|
|
if (entityzombie != null) {
|
2023-06-07 17:30:00 +02:00
|
|
|
entityzombie.handleAttributes(entityzombie.level().getCurrentDifficultyAt(entityzombie.blockPosition()).getSpecialMultiplier());
|
2021-11-21 23:00:00 +01:00
|
|
|
entityzombie.setCanBreakDoors(entityzombie.supportsBreakDoorGoal() && this.canBreakDoors());
|
2021-01-31 00:08:41 +01:00
|
|
|
+ // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam
|
|
|
|
+ } else {
|
|
|
|
+ ((Zombie) getBukkitEntity()).setConversionTime(-1);
|
|
|
|
+ // CraftBukkit end
|
2018-07-26 14:02:02 +02:00
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
|
2018-07-26 14:02:02 +02:00
|
|
|
}
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -305,9 +324,9 @@
|
|
|
|
if (EntityPositionTypes.isSpawnPositionOk(entitytypes, this.level(), blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level().random)) {
|
2021-11-21 23:00:00 +01:00
|
|
|
entityzombie.setPos((double) i1, (double) j1, (double) k1);
|
2023-06-07 17:30:00 +02:00
|
|
|
if (!this.level().hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level().isUnobstructed(entityzombie) && this.level().noCollision((Entity) entityzombie) && !this.level().containsAnyLiquid(entityzombie.getBoundingBox())) {
|
2021-11-21 23:00:00 +01:00
|
|
|
- entityzombie.setTarget(entityliving);
|
|
|
|
+ entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
|
2024-04-23 17:15:00 +02:00
|
|
|
entityzombie.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null);
|
2021-11-21 23:00:00 +01:00
|
|
|
- worldserver.addFreshEntityWithPassengers(entityzombie);
|
|
|
|
+ worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
2024-04-23 17:15:00 +02:00
|
|
|
this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADD_VALUE));
|
|
|
|
entityzombie.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADD_VALUE));
|
2020-08-11 23:00:00 +02:00
|
|
|
break;
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -328,7 +347,14 @@
|
2023-06-07 17:30:00 +02:00
|
|
|
float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) {
|
2024-04-23 17:15:00 +02:00
|
|
|
- entity.igniteForSeconds(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
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
2024-04-23 17:15:00 +02:00
|
|
|
+ entity.igniteForSeconds(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
|
|
|
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -403,8 +429,17 @@
|
2022-12-07 17:00:00 +01:00
|
|
|
if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) {
|
|
|
|
return flag;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2018-11-14 04:10:22 +01:00
|
|
|
+ // CraftBukkit start
|
2022-06-07 18:00:00 +02:00
|
|
|
+ flag = zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null;
|
2022-04-15 05:48:55 +02:00
|
|
|
+ }
|
2020-08-11 23:00:00 +02:00
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false);
|
2022-06-07 18:00:00 +02:00
|
|
|
+ return flag;
|
|
|
|
+ }
|
|
|
|
+
|
2022-04-18 03:05:15 +02:00
|
|
|
+ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) {
|
2022-12-07 17:00:00 +01:00
|
|
|
+ {
|
|
|
|
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason);
|
2022-04-15 05:48:55 +02:00
|
|
|
+ // CraftBukkit end
|
2022-12-07 17:00:00 +01:00
|
|
|
|
|
|
|
if (entityzombievillager != null) {
|
2024-04-23 17:15:00 +02:00
|
|
|
entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true));
|
|
|
|
@@ -412,15 +447,17 @@
|
2022-12-07 17:00:00 +01:00
|
|
|
entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE));
|
2024-04-23 17:15:00 +02:00
|
|
|
entityzombievillager.setTradeOffers(entityvillager.getOffers().copy());
|
2022-12-07 17:00:00 +01:00
|
|
|
entityzombievillager.setVillagerXp(entityvillager.getVillagerXp());
|
|
|
|
- if (!this.isSilent()) {
|
|
|
|
- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!silent) {
|
|
|
|
+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
- flag = false;
|
|
|
|
+ // flag = false;
|
2022-04-15 05:48:55 +02:00
|
|
|
}
|
2022-12-07 17:00:00 +01:00
|
|
|
- }
|
2022-04-15 05:48:55 +02:00
|
|
|
|
2022-06-07 18:00:00 +02:00
|
|
|
- return flag;
|
2022-12-07 17:00:00 +01:00
|
|
|
+ return entityzombievillager;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2022-04-15 05:48:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -471,7 +508,7 @@
|
|
|
|
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null);
|
2022-12-07 17:00:00 +01:00
|
|
|
entitychicken1.setChickenJockey(true);
|
|
|
|
this.startRiding(entitychicken1);
|
|
|
|
- worldaccess.addFreshEntity(entitychicken1);
|
|
|
|
+ worldaccess.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|