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

121 Zeilen
6.0 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityZombie.java
+++ b/net/minecraft/server/EntityZombie.java
2016-05-10 13:47:39 +02:00
@@ -5,6 +5,13 @@
import java.util.UUID;
2016-05-10 13:47:39 +02:00
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 {
2015-02-26 23:41:06 +01:00
protected static final IAttribute a = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
2016-05-10 13:47:39 +02:00
@@ -19,6 +26,7 @@
private boolean bC = false;
private float bD = -1.0F;
private float bE;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public EntityZombie(World world) {
super(world);
2016-05-10 13:47:39 +02:00
@@ -153,7 +161,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
}
}
}
2016-05-10 13:47:39 +02:00
@@ -183,8 +198,8 @@
2016-02-29 22:32:46 +01:00
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.getBoundingBox(), (Entity) entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !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);
2016-02-29 22:32:46 +01:00
entityzombie.prepare(this.world.D(new BlockPosition(entityzombie)), (GroupDataEntity) null);
2015-02-26 23:41:06 +01:00
this.getAttributeInstance(EntityZombie.a).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
entityzombie.getAttributeInstance(EntityZombie.a).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
2016-05-10 13:47:39 +02:00
@@ -203,6 +218,11 @@
2016-02-29 22:32:46 +01:00
public void m() {
if (!this.world.isClientSide && this.isConverting()) {
int i = this.getConversionTime();
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+ i *= elapsedTicks;
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
2016-05-10 13:47:39 +02:00
this.bB -= i;
if (this.bB <= 0) {
@@ -220,7 +240,14 @@
int i = this.world.getDifficulty().a();
2016-02-29 22:32:46 +01:00
if (this.getItemInMainHand() == null && this.isBurning() && this.random.nextFloat() < (float) i * 0.3F) {
- entity.setOnFire(2 * i);
+ // CraftBukkit start
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * i);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ entity.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
}
}
2016-05-10 13:47:39 +02:00
@@ -323,7 +350,7 @@
2016-02-29 22:32:46 +01:00
entityzombie.setCustomNameVisible(entityvillager.getCustomNameVisible());
}
- this.world.addEntity(entityzombie);
+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
2016-02-29 22:32:46 +01:00
this.world.a((EntityHuman) null, 1026, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
}
2016-05-10 13:47:39 +02:00
@@ -377,7 +404,7 @@
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null);
2016-02-29 22:32:46 +01:00
entitychicken1.o(true);
- this.world.addEntity(entitychicken1);
2016-02-29 22:32:46 +01:00
+ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
this.startRiding(entitychicken1);
}
}
2016-05-10 13:47:39 +02:00
@@ -461,7 +488,7 @@
2015-02-26 23:41:06 +01:00
entityvillager.setCustomNameVisible(this.getCustomNameVisible());
}
- this.world.addEntity(entityvillager);
+ this.world.addEntity(entityvillager, CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
2016-02-29 22:32:46 +01:00
entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
}
2016-05-10 13:47:39 +02:00
@@ -517,11 +544,12 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // CraftBukkit
2016-02-29 22:32:46 +01:00
if (damagesource.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
2016-03-07 09:51:42 +01:00
this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F);
}
+ super.die(damagesource); // CraftBukkit - moved from above
2016-03-07 09:51:42 +01:00
}