Fix issues with mob conversion (#6831)

This commit is contained in:
Jake Potrebic 2021-11-05 17:06:19 -07:00
parent 0b77f9e66b
commit a8448bef56
2 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 24 Oct 2021 20:29:27 -0700
Subject: [PATCH] Fix issues with mob conversion
diff --git a/src/main/java/org/bukkit/entity/PiglinAbstract.java b/src/main/java/org/bukkit/entity/PiglinAbstract.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/PiglinAbstract.java
+++ b/src/main/java/org/bukkit/entity/PiglinAbstract.java
@@ -0,0 +0,0 @@ public interface PiglinAbstract extends Monster, Ageable {
public int getConversionTime();
/**
- * Sets the amount of ticks until this entity will be converted to a
- * Zombified Piglin.
+ * Sets the conversion counter value. The counter is incremented
+ * every tick the {@link #isConverting()} returns true. Setting this
+ * value will not start the conversion if the {@link PiglinAbstract} is
+ * not in a valid environment ({@link org.bukkit.World#isPiglinSafe})
+ * to convert or {@link #isImmuneToZombification()} is true or
+ * has no AI.
*
- * When this reaches 0, the entity will be converted. A value of less than 0
- * will stop the current conversion process without converting the current
- * entity.
+ * When this reaches 300, the entity will be converted. To stop the
+ * conversion use {@link #setImmuneToZombification(boolean)}.
*
- * @param time new conversion time
+ * @param time new conversion counter
*/
public void setConversionTime(int time);

View File

@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 24 Oct 2021 20:29:45 -0700
Subject: [PATCH] Fix issues with mob conversion
diff --git a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
@@ -0,0 +0,0 @@ public class Skeleton extends AbstractSkeleton {
}
protected void doFreezeConversion() {
- this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons
- if (!this.isSilent()) {
+ Stray stray = this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons // Paper - track result of conversion
+ if (stray != null && !this.isSilent()) { // Paper - only send event if conversion succeeded
this.level.levelEvent((Player) null, 1048, this.blockPosition(), 0);
}
+ // Paper start - reset conversion time to prevent event spam
+ if (stray == null) {
+ this.conversionTime = 300;
+ }
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
@@ -0,0 +0,0 @@ public abstract class AbstractPiglin extends Monster {
if (entitypigzombie != null) {
entitypigzombie.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
}
+ // Paper start - reset to prevent event spam
+ else {
+ this.timeInOverworld = 0;
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
@@ -0,0 +0,0 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton {
this.getHandle().conversionTime = -1;
this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.Skeleton.DATA_STRAY_CONVERSION_ID, false);
} else {
- this.getHandle().getSwimAmount(time); // PAIL rename startStrayConversion
+ this.getHandle().startFreezeConversion(time); // PAIL rename startStrayConversion // Paper - nope, that's not the right method
}
}