From 695baf4481323bd009dffe6a9a622653a5f44691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ZX=E5=A4=8F=E5=A4=9C=E4=B9=8B=E9=A3=8E?= Date: Fri, 8 Nov 2024 23:54:05 +0800 Subject: [PATCH] fix: backport of #3177 (#3179) * fix: backport of #3177 1.8 backport may not work well because no DataWatcher for fuse in that version, and we can't support it as it is really an old version. It is just a theoretical fix. * fix: leave fuse ticks very long in MC 1.8 fix --- .../v1_10_R1/entity/nonliving/TNTPrimedController.java | 6 ++++++ .../v1_11_R1/entity/nonliving/TNTPrimedController.java | 6 ++++++ .../v1_12_R1/entity/nonliving/TNTPrimedController.java | 6 ++++++ .../v1_13_R2/entity/nonliving/TNTPrimedController.java | 6 ++++++ .../v1_14_R1/entity/nonliving/TNTPrimedController.java | 6 ++++++ .../v1_15_R1/entity/nonliving/TNTPrimedController.java | 6 ++++++ .../v1_16_R3/entity/nonliving/TNTPrimedController.java | 6 ++++++ .../v1_17_R1/entity/nonliving/TNTPrimedController.java | 7 +++++++ .../v1_18_R2/entity/nonliving/TNTPrimedController.java | 7 +++++++ .../v1_19_R3/entity/nonliving/TNTPrimedController.java | 7 +++++++ .../v1_20_R4/entity/nonliving/TNTPrimedController.java | 7 +++++++ .../v1_8_R3/entity/nonliving/TNTPrimedController.java | 10 ++++++++++ 12 files changed, 80 insertions(+) diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/TNTPrimedController.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/TNTPrimedController.java index fd60d2930..bf655cf2d 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/TNTPrimedController.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/TNTPrimedController.java @@ -93,9 +93,15 @@ public class TNTPrimedController extends MobEntityController { return npc; } + private int fuseRenewalDelay = 9; @Override public void m() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + setFuseTicks(Integer.MAX_VALUE - 1); + setFuseTicks(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.m(); diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/TNTPrimedController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/TNTPrimedController.java index 27749632f..4ed857e81 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/TNTPrimedController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/TNTPrimedController.java @@ -52,9 +52,15 @@ public class TNTPrimedController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.a(player)); } + private int fuseRenewalDelay = 9; @Override public void A_() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + setFuseTicks(Integer.MAX_VALUE - 1); + setFuseTicks(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.A_(); diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/TNTPrimedController.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/TNTPrimedController.java index 1e2c39d21..180fb1f64 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/TNTPrimedController.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/TNTPrimedController.java @@ -53,9 +53,15 @@ public class TNTPrimedController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.a(player)); } + private int fuseRenewalDelay = 9; @Override public void B_() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + setFuseTicks(Integer.MAX_VALUE - 1); + setFuseTicks(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.B_(); diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/TNTPrimedController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/TNTPrimedController.java index 19fd07343..8a1588533 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/TNTPrimedController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/TNTPrimedController.java @@ -112,9 +112,15 @@ public class TNTPrimedController extends MobEntityController { return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); } + private int fuseRenewalDelay = 9; @Override public void tick() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + setFuseTicks(Integer.MAX_VALUE - 1); + setFuseTicks(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.tick(); diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/TNTPrimedController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/TNTPrimedController.java index f0512e3d0..ab8710b7c 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/TNTPrimedController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/TNTPrimedController.java @@ -111,9 +111,15 @@ public class TNTPrimedController extends MobEntityController { return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); } + private int fuseRenewalDelay = 9; @Override public void tick() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + setFuseTicks(Integer.MAX_VALUE - 1); + setFuseTicks(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.tick(); diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/TNTPrimedController.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/TNTPrimedController.java index f42b2a6e1..fa584e3d2 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/TNTPrimedController.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/TNTPrimedController.java @@ -112,9 +112,15 @@ public class TNTPrimedController extends MobEntityController { } } + private int fuseRenewalDelay = 9; @Override public void tick() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + setFuseTicks(Integer.MAX_VALUE - 1); + setFuseTicks(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.tick(); diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/TNTPrimedController.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/TNTPrimedController.java index bd295dcf9..3b9f47d30 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/TNTPrimedController.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/TNTPrimedController.java @@ -112,10 +112,16 @@ public class TNTPrimedController extends MobEntityController { } } + private int fuseRenewalDelay = 9; @Override public void tick() { if (npc != null) { npc.update(); + if (fuseRenewalDelay-- <= 0) { + setFuseTicks(Integer.MAX_VALUE - 1); + setFuseTicks(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } } else { super.tick(); } diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/TNTPrimedController.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/TNTPrimedController.java index b73c42793..ee26e9155 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/TNTPrimedController.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/TNTPrimedController.java @@ -107,9 +107,16 @@ public class TNTPrimedController extends MobEntityController { return npc == null ? super.save(save) : false; } + private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like @Override public void tick() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + // DataWatcher refuses to mark dirty if we don't give different values + setFuse(Integer.MAX_VALUE - 1); + setFuse(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.tick(); diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/TNTPrimedController.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/TNTPrimedController.java index 1e5ad0af3..533b21536 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/TNTPrimedController.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/TNTPrimedController.java @@ -116,9 +116,16 @@ public class TNTPrimedController extends MobEntityController { return NMSImpl.teleportAcrossWorld(this, worldserver, location); } + private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like @Override public void tick() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + // DataWatcher refuses to mark dirty if we don't give different values + setFuse(Integer.MAX_VALUE - 1); + setFuse(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.tick(); diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/TNTPrimedController.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/TNTPrimedController.java index 41f2e8def..f10b22251 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/TNTPrimedController.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/TNTPrimedController.java @@ -116,9 +116,16 @@ public class TNTPrimedController extends MobEntityController { return NMSImpl.teleportAcrossWorld(this, worldserver, location); } + private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like @Override public void tick() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + // DataWatcher refuses to mark dirty if we don't give different values + setFuse(Integer.MAX_VALUE - 1); + setFuse(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.tick(); diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/TNTPrimedController.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/TNTPrimedController.java index 2a993e183..a85db9e3d 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/TNTPrimedController.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/TNTPrimedController.java @@ -106,9 +106,16 @@ public class TNTPrimedController extends MobEntityController { return NMSImpl.teleportAcrossWorld(this, worldserver, location); } + private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like @Override public void tick() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + // DataWatcher refuses to mark dirty if we don't give different values + setFuse(Integer.MAX_VALUE - 1); + setFuse(Integer.MAX_VALUE); + fuseRenewalDelay = 9; + } npc.update(); } else { super.tick(); diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/TNTPrimedController.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/TNTPrimedController.java index d08176013..fa3646bd9 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/TNTPrimedController.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/TNTPrimedController.java @@ -1,5 +1,7 @@ package net.citizensnpcs.nms.v1_8_R3.entity.nonliving; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateEntityNBT; +import net.minecraft.server.v1_8_R3.WorldServer; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; @@ -40,6 +42,7 @@ public class TNTPrimedController extends MobEntityController { public EntityTNTPrimedNPC(World world, NPC npc) { super(world); this.npc = (CitizensNPC) npc; + this.fuseTicks = Integer.MAX_VALUE; } @Override @@ -93,9 +96,16 @@ public class TNTPrimedController extends MobEntityController { return npc; } + private int fuseRenewalDelay = 9; @Override public void t_() { if (npc != null) { + if (fuseRenewalDelay-- <= 0) { + final NBTTagCompound nbtTagCompound = new NBTTagCompound(); + e(nbtTagCompound); // dump the entity NBT so let client update it as we don't have DataWatcher for fuse in this MC version + ((WorldServer) getWorld()).getTracker().a(this, new PacketPlayOutUpdateEntityNBT(getId(), nbtTagCompound)); + fuseRenewalDelay = 9; + } npc.update(); } else { super.t_();