Fix issues with mob conversion

This commit is contained in:
Jake Potrebic 2021-10-24 20:29:45 -07:00
parent 2852803dbf
commit 310d8c53aa
3 changed files with 38 additions and 7 deletions

View file

@ -1,11 +1,24 @@
--- a/net/minecraft/world/entity/monster/Skeleton.java
+++ b/net/minecraft/world/entity/monster/Skeleton.java
@@ -99,7 +99,7 @@
@@ -94,12 +94,19 @@
}
protected void doFreezeConversion() {
- this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), (entityskeletonstray) -> {
+ final Stray stray = this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), (entityskeletonstray) -> { // Paper - Fix issues with mob conversion; reset conversion time to prevent event spam
if (!this.isSilent()) {
this.level().levelEvent((Player) null, 1048, this.blockPosition(), 0);
}
- });
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN);// CraftBukkit - add spawn and transform reasons
+
+ // Paper start - Fix issues with mob conversion; reset conversion time to prevent event spam
+ if (stray == null) {
+ this.conversionTime = 300;
+ }
+ // Paper end - Fix issues with mob conversion
+
}
@Override

View file

@ -19,16 +19,25 @@
}
@Override
@@ -242,7 +243,7 @@
@@ -240,9 +241,15 @@
}
private void finishConversion() {
this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), (entityzoglin) -> {
- this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), (entityzoglin) -> {
+ net.minecraft.world.entity.Entity converted = this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), (entityzoglin) -> {
entityzoglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
- });
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
+
+ // Paper start - Fix issues with mob conversion; reset to prevent event spam
+ if (converted == null) {
+ this.timeInOverworld = 0;
+ }
+ // Paper end - Fix issues with mob conversion
}
@Override
@@ -326,7 +327,7 @@
@@ -326,7 +333,7 @@
@Override
protected SoundEvent getAmbientSound() {

View file

@ -1,11 +1,20 @@
--- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
+++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
@@ -102,7 +102,7 @@
@@ -100,9 +100,15 @@
}
protected void finishConversion(ServerLevel world) {
this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), (entitypigzombie) -> {
- this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), (entitypigzombie) -> {
+ net.minecraft.world.entity.Entity converted = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), (entitypigzombie) -> { // Paper - Fix issues with mob conversion; reset to prevent event spam
entitypigzombie.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
- });
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
+
+ // Paper start - Fix issues with mob conversion; reset to prevent event spam
+ if (converted == null) {
+ this.timeInOverworld = 0;
+ }
+ // Paper end - Fix issues with mob conversion
}
public boolean isAdult() {