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

123 Zeilen
6.8 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityZombie.java
+++ b/net/minecraft/server/EntityZombie.java
@@ -8,6 +8,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 {
2019-04-23 04:00:00 +02:00
protected static final IAttribute d = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
@@ -23,6 +32,7 @@
2019-12-10 23:00:00 +01:00
private boolean bB;
private int bC;
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);
@@ -144,7 +154,11 @@
public void tick() {
2019-04-23 04:00:00 +02:00
if (!this.world.isClientSide && this.isAlive()) {
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;
+ 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) {
2019-12-10 23:00:00 +01:00
this.ev();
}
@@ -193,6 +207,7 @@
}
public void startDrownedConversion(int i) {
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
this.drownedConversionTime = i;
this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true);
}
2019-12-10 23:00:00 +01:00
@@ -236,7 +251,13 @@
2018-07-26 14:02:02 +02:00
}
2019-12-10 23:00:00 +01:00
entityzombie.setInvulnerable(this.isInvulnerable());
2018-07-26 14:02:02 +02:00
- this.world.addEntity(entityzombie);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombie, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) {
+ ((Zombie) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
+ 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-12-10 23:00:00 +01:00
@@ -298,8 +319,8 @@
2019-04-23 04:00:00 +02:00
if (this.world.getType(blockposition).a((IBlockAccess) this.world, blockposition, (Entity) entityzombie) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
2019-04-23 04:00:00 +02:00
if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.i((Entity) 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
2019-04-23 04:00:00 +02:00
entityzombie.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombie)), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
2019-07-20 01:00:00 +02:00
this.getAttributeInstance(EntityZombie.d).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
entityzombie.getAttributeInstance(EntityZombie.d).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
2019-12-10 23:00:00 +01:00
@@ -323,7 +344,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(), false);
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
}
}
2019-12-10 23:00:00 +01:00
@@ -413,7 +441,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
entityzombievillager.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombievillager)), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null);
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
2019-12-10 23:00:00 +01:00
entityzombievillager.a((NBTBase) entityvillager.eN().a((DynamicOps) DynamicOpsNBT.a).getValue());
@@ -431,7 +459,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
2016-11-17 02:41:03 +01:00
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
}
2019-12-10 23:00:00 +01:00
@@ -478,7 +512,7 @@
entitychicken1.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F);
2019-04-23 04:00:00 +02:00
entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.r(true);
- generatoraccess.addEntity(entitychicken1);
+ generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
2016-02-29 22:32:46 +01:00
this.startRiding(entitychicken1);
}
}