3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 23:00:08 +01:00
Paper/nms-patches/EntityZombie.patch

123 Zeilen
6.6 KiB
Diff

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;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Zombie;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+// CraftBukkit end
+
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");
@@ -23,6 +32,7 @@
2020-06-25 02:00:00 +02:00
private boolean bz;
private int bA;
2018-12-25 22:00:00 +01:00
public int drownedConversionTime;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
2019-04-23 04:00:00 +02:00
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
super(entitytypes, world);
2020-06-25 02:00:00 +02:00
@@ -138,7 +148,10 @@
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
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
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) {
2020-06-25 02:00:00 +02:00
this.eQ();
}
2020-06-25 02:00:00 +02:00
@@ -155,6 +168,7 @@
}
super.tick();
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
}
@Override
2020-06-25 02:00:00 +02:00
@@ -187,6 +201,7 @@
}
public void startDrownedConversion(int i) {
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
this.drownedConversionTime = i;
this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true);
}
2020-06-25 02:00:00 +02:00
@@ -206,6 +221,7 @@
entityzombie.u(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d());
entityzombie.u(entityzombie.eL() && this.eV());
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
@@ -239,8 +255,8 @@
if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, this.world, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) {
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
2020-06-25 02:00:00 +02:00
if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.i(entityzombie) && this.world.getCubes(entityzombie) && !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
2020-06-25 02:00:00 +02:00
entityzombie.prepare(this.world, this.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
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));
@@ -264,7 +280,14 @@
float f = this.world.getDamageScaler(this.getChunkCoordinates()).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(), false);
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
}
}
2020-06-25 02:00:00 +02:00
@@ -354,7 +377,7 @@
2019-04-23 04:00:00 +02:00
EntityZombieVillager entityzombievillager = (EntityZombieVillager) EntityTypes.ZOMBIE_VILLAGER.a(this.world);
entityzombievillager.u(entityvillager);
2019-04-23 04:00:00 +02:00
- entityvillager.die();
+ // entityvillager.die(); // CraftBukkit - moved down
2020-06-25 02:00:00 +02:00
entityzombievillager.prepare(this.world, this.world.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null);
2019-04-23 04:00:00 +02:00
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
2020-06-25 02:00:00 +02:00
entityzombievillager.a((NBTBase) entityvillager.fj().a((DynamicOps) DynamicOpsNBT.a).getValue());
@@ -372,7 +395,13 @@
}
2019-12-10 23:00:00 +01:00
entityzombievillager.setInvulnerable(this.isInvulnerable());
2016-11-17 02:41:03 +01:00
- this.world.addEntity(entityzombievillager);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ return;
+ }
2019-04-23 04:00:00 +02:00
+ entityvillager.die(); // CraftBukkit - from above
2016-11-17 02:41:03 +01:00
+ this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
if (!this.isSilent()) {
this.world.a((EntityHuman) null, 1026, this.getChunkCoordinates(), 0);
}
@@ -423,7 +452,7 @@
entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.setChickenJockey(true);
this.startRiding(entitychicken1);
- generatoraccess.addEntity(entitychicken1);
+ generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
}
}
}