mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 06:50:12 +01:00
SPIGOT-5208: Reset state on cancelled EntityTransformEvent to prevent event spam
This commit is contained in:
parent
f744c09c02
commit
c88867e4fc
4 changed files with 24 additions and 19 deletions
|
@ -1,18 +1,17 @@
|
|||
--- a/net/minecraft/server/EntityPig.java
|
||||
+++ b/net/minecraft/server/EntityPig.java
|
||||
@@ -2,6 +2,11 @@
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityPig extends EntityAnimal {
|
||||
|
||||
private static final DataWatcherObject<Boolean> bz = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i);
|
||||
@@ -163,7 +168,13 @@
|
||||
@@ -163,7 +167,13 @@
|
||||
entitypigzombie.setCustomNameVisible(this.getCustomNameVisible());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
--- a/net/minecraft/server/EntityZombie.java
|
||||
+++ b/net/minecraft/server/EntityZombie.java
|
||||
@@ -8,6 +8,14 @@
|
||||
@@ -8,6 +8,15 @@
|
||||
import java.util.function.Predicate;
|
||||
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;
|
||||
|
@ -15,7 +16,7 @@
|
|||
public class EntityZombie extends EntityMonster {
|
||||
|
||||
protected static final IAttribute d = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
|
||||
@@ -23,6 +31,7 @@
|
||||
@@ -23,6 +32,7 @@
|
||||
private boolean bE;
|
||||
private int bF;
|
||||
public int drownedConversionTime;
|
||||
|
@ -23,7 +24,7 @@
|
|||
|
||||
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -144,7 +153,11 @@
|
||||
@@ -144,7 +154,11 @@
|
||||
public void tick() {
|
||||
if (!this.world.isClientSide && this.isAlive()) {
|
||||
if (this.isDrownConverting()) {
|
||||
|
@ -36,7 +37,7 @@
|
|||
if (this.drownedConversionTime < 0) {
|
||||
this.ea();
|
||||
}
|
||||
@@ -193,6 +206,7 @@
|
||||
@@ -193,6 +207,7 @@
|
||||
}
|
||||
|
||||
public void startDrownedConversion(int i) {
|
||||
|
@ -44,13 +45,14 @@
|
|||
this.drownedConversionTime = i;
|
||||
this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true);
|
||||
}
|
||||
@@ -231,7 +245,12 @@
|
||||
@@ -231,7 +246,13 @@
|
||||
entityzombie.setCustomNameVisible(this.getCustomNameVisible());
|
||||
}
|
||||
|
||||
- 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
|
||||
|
@ -58,7 +60,7 @@
|
|||
this.die();
|
||||
}
|
||||
}
|
||||
@@ -264,8 +283,8 @@
|
||||
@@ -264,8 +285,8 @@
|
||||
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);
|
||||
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())) {
|
||||
|
@ -69,7 +71,7 @@
|
|||
entityzombie.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombie)), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
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));
|
||||
@@ -289,7 +308,14 @@
|
||||
@@ -289,7 +310,14 @@
|
||||
float f = this.world.getDamageScaler(new BlockPosition(this)).b();
|
||||
|
||||
if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) {
|
||||
|
@ -85,7 +87,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -379,7 +405,7 @@
|
||||
@@ -379,7 +407,7 @@
|
||||
EntityZombieVillager entityzombievillager = (EntityZombieVillager) EntityTypes.ZOMBIE_VILLAGER.a(this.world);
|
||||
|
||||
entityzombievillager.u(entityvillager);
|
||||
|
@ -94,7 +96,7 @@
|
|||
entityzombievillager.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombievillager)), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null);
|
||||
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
|
||||
entityzombievillager.a((NBTBase) entityvillager.es().a((DynamicOps) DynamicOpsNBT.a).getValue());
|
||||
@@ -392,7 +418,13 @@
|
||||
@@ -392,7 +420,13 @@
|
||||
entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible());
|
||||
}
|
||||
|
||||
|
@ -109,7 +111,7 @@
|
|||
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
|
||||
}
|
||||
|
||||
@@ -439,7 +471,7 @@
|
||||
@@ -439,7 +473,7 @@
|
||||
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
|
||||
entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
entitychicken1.r(true);
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
--- a/net/minecraft/server/EntityZombieVillager.java
|
||||
+++ b/net/minecraft/server/EntityZombieVillager.java
|
||||
@@ -3,6 +3,10 @@
|
||||
@@ -3,6 +3,11 @@
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.ZombieVillager;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder {
|
||||
|
||||
@@ -13,6 +17,7 @@
|
||||
@@ -13,6 +18,7 @@
|
||||
private NBTBase bB;
|
||||
private NBTTagCompound bC;
|
||||
private int bD;
|
||||
|
@ -19,7 +20,7 @@
|
|||
|
||||
public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -75,6 +80,11 @@
|
||||
@@ -75,6 +81,11 @@
|
||||
public void tick() {
|
||||
if (!this.world.isClientSide && this.isAlive() && this.isConverting()) {
|
||||
int i = this.getConversionProgress();
|
||||
|
@ -31,7 +32,7 @@
|
|||
|
||||
this.conversionTime -= i;
|
||||
if (this.conversionTime <= 0) {
|
||||
@@ -122,8 +132,11 @@
|
||||
@@ -122,8 +133,11 @@
|
||||
this.conversionPlayer = uuid;
|
||||
this.conversionTime = i;
|
||||
this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true);
|
||||
|
@ -45,7 +46,7 @@
|
|||
this.world.broadcastEntityEffect(this, (byte) 16);
|
||||
}
|
||||
|
||||
@@ -146,14 +159,20 @@
|
||||
@@ -146,14 +160,21 @@
|
||||
entityvillager.setAgeRaw(-24000);
|
||||
}
|
||||
|
||||
|
@ -60,6 +61,7 @@
|
|||
- worldserver.addEntity(entityvillager);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) {
|
||||
+ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
|
||||
+ return;
|
||||
+ }
|
||||
+ this.die(); // CraftBukkit - from above
|
||||
|
@ -68,7 +70,7 @@
|
|||
if (this.conversionPlayer != null) {
|
||||
EntityHuman entityhuman = worldserver.b(this.conversionPlayer);
|
||||
|
||||
@@ -163,7 +182,7 @@
|
||||
@@ -163,7 +184,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.UUID;
|
|||
import net.minecraft.server.EntityZombieVillager;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.MobEffects;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -65,6 +66,7 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager {
|
|||
getHandle().getDataWatcher().set(EntityZombieVillager.CONVERTING, false);
|
||||
getHandle().persistent = false; // CraftBukkit - SPIGOT-4684 update persistence
|
||||
getHandle().conversionPlayer = null;
|
||||
getHandle().removeEffect(MobEffects.INCREASE_DAMAGE, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
} else {
|
||||
getHandle().startConversion((UUID) null, time);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue