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
This commit is contained in:
ZX夏夜之风 2024-11-08 23:54:05 +08:00 committed by GitHub
parent 080bf9ce3d
commit 695baf4481
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 80 additions and 0 deletions

View File

@ -93,9 +93,15 @@ public class TNTPrimedController extends MobEntityController {
return npc; return npc;
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void m() { public void m() {
if (npc != null) { if (npc != null) {
if (fuseRenewalDelay-- <= 0) {
setFuseTicks(Integer.MAX_VALUE - 1);
setFuseTicks(Integer.MAX_VALUE);
fuseRenewalDelay = 9;
}
npc.update(); npc.update();
} else { } else {
super.m(); super.m();

View File

@ -52,9 +52,15 @@ public class TNTPrimedController extends MobEntityController {
return NMS.shouldBroadcastToPlayer(npc, () -> super.a(player)); return NMS.shouldBroadcastToPlayer(npc, () -> super.a(player));
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void A_() { public void A_() {
if (npc != null) { if (npc != null) {
if (fuseRenewalDelay-- <= 0) {
setFuseTicks(Integer.MAX_VALUE - 1);
setFuseTicks(Integer.MAX_VALUE);
fuseRenewalDelay = 9;
}
npc.update(); npc.update();
} else { } else {
super.A_(); super.A_();

View File

@ -53,9 +53,15 @@ public class TNTPrimedController extends MobEntityController {
return NMS.shouldBroadcastToPlayer(npc, () -> super.a(player)); return NMS.shouldBroadcastToPlayer(npc, () -> super.a(player));
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void B_() { public void B_() {
if (npc != null) { if (npc != null) {
if (fuseRenewalDelay-- <= 0) {
setFuseTicks(Integer.MAX_VALUE - 1);
setFuseTicks(Integer.MAX_VALUE);
fuseRenewalDelay = 9;
}
npc.update(); npc.update();
} else { } else {
super.B_(); super.B_();

View File

@ -112,9 +112,15 @@ public class TNTPrimedController extends MobEntityController {
return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction();
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void tick() { public void tick() {
if (npc != null) { if (npc != null) {
if (fuseRenewalDelay-- <= 0) {
setFuseTicks(Integer.MAX_VALUE - 1);
setFuseTicks(Integer.MAX_VALUE);
fuseRenewalDelay = 9;
}
npc.update(); npc.update();
} else { } else {
super.tick(); super.tick();

View File

@ -111,9 +111,15 @@ public class TNTPrimedController extends MobEntityController {
return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction();
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void tick() { public void tick() {
if (npc != null) { if (npc != null) {
if (fuseRenewalDelay-- <= 0) {
setFuseTicks(Integer.MAX_VALUE - 1);
setFuseTicks(Integer.MAX_VALUE);
fuseRenewalDelay = 9;
}
npc.update(); npc.update();
} else { } else {
super.tick(); super.tick();

View File

@ -112,9 +112,15 @@ public class TNTPrimedController extends MobEntityController {
} }
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void tick() { public void tick() {
if (npc != null) { if (npc != null) {
if (fuseRenewalDelay-- <= 0) {
setFuseTicks(Integer.MAX_VALUE - 1);
setFuseTicks(Integer.MAX_VALUE);
fuseRenewalDelay = 9;
}
npc.update(); npc.update();
} else { } else {
super.tick(); super.tick();

View File

@ -112,10 +112,16 @@ public class TNTPrimedController extends MobEntityController {
} }
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void tick() { public void tick() {
if (npc != null) { if (npc != null) {
npc.update(); npc.update();
if (fuseRenewalDelay-- <= 0) {
setFuseTicks(Integer.MAX_VALUE - 1);
setFuseTicks(Integer.MAX_VALUE);
fuseRenewalDelay = 9;
}
} else { } else {
super.tick(); super.tick();
} }

View File

@ -107,9 +107,16 @@ public class TNTPrimedController extends MobEntityController {
return npc == null ? super.save(save) : false; return npc == null ? super.save(save) : false;
} }
private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like
@Override @Override
public void tick() { public void tick() {
if (npc != null) { 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(); npc.update();
} else { } else {
super.tick(); super.tick();

View File

@ -116,9 +116,16 @@ public class TNTPrimedController extends MobEntityController {
return NMSImpl.teleportAcrossWorld(this, worldserver, location); return NMSImpl.teleportAcrossWorld(this, worldserver, location);
} }
private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like
@Override @Override
public void tick() { public void tick() {
if (npc != null) { 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(); npc.update();
} else { } else {
super.tick(); super.tick();

View File

@ -116,9 +116,16 @@ public class TNTPrimedController extends MobEntityController {
return NMSImpl.teleportAcrossWorld(this, worldserver, location); return NMSImpl.teleportAcrossWorld(this, worldserver, location);
} }
private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like
@Override @Override
public void tick() { public void tick() {
if (npc != null) { 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(); npc.update();
} else { } else {
super.tick(); super.tick();

View File

@ -106,9 +106,16 @@ public class TNTPrimedController extends MobEntityController {
return NMSImpl.teleportAcrossWorld(this, worldserver, location); return NMSImpl.teleportAcrossWorld(this, worldserver, location);
} }
private int fuseRenewalDelay = 9; // give client some time to make the animation look vanilla-like
@Override @Override
public void tick() { public void tick() {
if (npc != null) { 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(); npc.update();
} else { } else {
super.tick(); super.tick();

View File

@ -1,5 +1,7 @@
package net.citizensnpcs.nms.v1_8_R3.entity.nonliving; 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.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
@ -40,6 +42,7 @@ public class TNTPrimedController extends MobEntityController {
public EntityTNTPrimedNPC(World world, NPC npc) { public EntityTNTPrimedNPC(World world, NPC npc) {
super(world); super(world);
this.npc = (CitizensNPC) npc; this.npc = (CitizensNPC) npc;
this.fuseTicks = Integer.MAX_VALUE;
} }
@Override @Override
@ -93,9 +96,16 @@ public class TNTPrimedController extends MobEntityController {
return npc; return npc;
} }
private int fuseRenewalDelay = 9;
@Override @Override
public void t_() { public void t_() {
if (npc != null) { 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(); npc.update();
} else { } else {
super.t_(); super.t_();