Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
de547749ec
Thanks Zach Brown for outline of issue with drowned zombies.
127 Zeilen
5.8 KiB
Diff
127 Zeilen
5.8 KiB
Diff
--- a/net/minecraft/server/EntityZombie.java
|
|
+++ b/net/minecraft/server/EntityZombie.java
|
|
@@ -6,6 +6,13 @@
|
|
import java.util.UUID;
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
+import org.bukkit.event.entity.EntityCombustEvent;
|
|
+import org.bukkit.event.entity.EntityTargetEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class EntityZombie extends EntityMonster {
|
|
|
|
protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
|
|
@@ -21,6 +28,7 @@
|
|
private int bJ;
|
|
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 +151,12 @@
|
|
|
|
public void tick() {
|
|
if (!this.world.isClientSide) {
|
|
- if (this.dG()) {
|
|
- --this.bJ;
|
|
+ // CraftBukkit start - Use wall time instead of ticks for conversion
|
|
+ if (this.dG() && this.isAlive()) {
|
|
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
|
+ this.lastTick = MinecraftServer.currentTick;
|
|
+ this.bJ -= elapsedTicks;
|
|
+ // CraftBukkit end
|
|
if (this.bJ < 0) {
|
|
this.dE();
|
|
}
|
|
@@ -182,7 +194,14 @@
|
|
}
|
|
|
|
if (flag) {
|
|
- this.setOnFire(8);
|
|
+ // CraftBukkit start
|
|
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (!event.isCancelled()) {
|
|
+ this.setOnFire(event.getDuration());
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
@@ -221,7 +240,7 @@
|
|
entityzombie.setCustomNameVisible(this.getCustomNameVisible());
|
|
}
|
|
|
|
- this.world.addEntity(entityzombie);
|
|
+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.DROWNED); // CraftBukkit - added spawn reason
|
|
this.die();
|
|
}
|
|
}
|
|
@@ -252,8 +271,8 @@
|
|
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);
|
|
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
|
|
+ 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 +295,14 @@
|
|
float f = this.world.getDamageScaler(new BlockPosition(this)).b();
|
|
|
|
if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) {
|
|
- entity.setOnFire(2 * (int) f);
|
|
+ // CraftBukkit start
|
|
+ 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
|
|
}
|
|
}
|
|
|
|
@@ -372,7 +398,7 @@
|
|
entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible());
|
|
}
|
|
|
|
- this.world.addEntity(entityzombievillager);
|
|
+ this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
|
|
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
|
|
}
|
|
|
|
@@ -422,7 +448,7 @@
|
|
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
|
|
entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null);
|
|
entitychicken1.s(true);
|
|
- this.world.addEntity(entitychicken1);
|
|
+ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
|
|
this.startRiding(entitychicken1);
|
|
}
|
|
}
|
|
@@ -495,7 +521,7 @@
|
|
}
|
|
|
|
public void die(DamageSource damagesource) {
|
|
- super.die(damagesource);
|
|
+ // super.die(damagesource); // CraftBukkit
|
|
if (damagesource.getEntity() instanceof EntityCreeper) {
|
|
EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
|
|
|
|
@@ -508,6 +534,7 @@
|
|
}
|
|
}
|
|
}
|
|
+ super.die(damagesource); // CraftBukkit - moved from above
|
|
|
|
}
|
|
|