Merge branch 'dev' into syntax-highlighter-unified

This commit is contained in:
Kam committed 2026-03-04 16:21:29 -05:00
commit c5cd2d7ce1
9 files changed
+160 -41

No files matched your search

+1 -1
View File
@@ -124,7 +124,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.11-beta13")
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.11-beta13.1")
public class CustomNpcs {
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
@@ -14,6 +14,7 @@ import noppes.npcs.scripted.NpcAPI;
import javax.script.Bindings;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import java.io.PrintWriter;
@@ -272,20 +273,18 @@ public class ScriptContainer implements IScriptUnit {
unknownFunctions.add(type);
}
} else {
if (!this.cachedFunctions.containsKey(type)) {
ScriptObjectMirror func;
if (instanceBindings != null) {
if (instanceBindings != null) {
if (!this.cachedFunctions.containsKey(type)) {
Object val = instanceBindings.get(type);
func = val instanceof ScriptObjectMirror ? (ScriptObjectMirror) val : null;
} else {
ScriptObjectMirror global = (ScriptObjectMirror) engine.getBindings(ScriptContext.ENGINE_SCOPE);
func = (ScriptObjectMirror) global.get(type);
ScriptObjectMirror func = val instanceof ScriptObjectMirror ? (ScriptObjectMirror) val : null;
this.cachedFunctions.put(type, func);
}
this.cachedFunctions.put(type, func);
}
ScriptObjectMirror func = this.cachedFunctions.get(type);
if (func != null) {
func.call(null, event);
ScriptObjectMirror func = this.cachedFunctions.get(type);
if (func != null) {
func.call(null, event);
}
} else {
((Invocable) engine).invokeFunction(type, event);
}
}
} catch (NoSuchMethodException e) {
@@ -8,6 +8,8 @@ import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.data.entry.AbilityToggleEntry;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.data.UpdateAnimationsPacket;
import kamkeel.npcs.network.packets.data.ability.AbilityCooldownSyncPacket;
import kamkeel.npcs.network.packets.data.ability.PlayerAbilityStatePacket;
import kamkeel.npcs.network.packets.data.ability.PlayerAbilitySyncPacket;
@@ -177,6 +179,22 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
protected void clearAnimationData() {
playerData.animationData.setAnimation(null);
playerData.animationData.updateClient();
// Directly send animation clear to the owning player. updateClient() uses
// getEntitiesWithinAABB to find recipients, but during teleport the player
// entity hasn't migrated to the new chunk yet — so the AABB search centered
// on the new position won't find them, and the clear packet is never delivered.
// This guarantees the player's client always receives the clear.
EntityPlayer player = playerData.player;
if (player instanceof EntityPlayerMP) {
NBTTagCompound data = new NBTTagCompound();
data.setBoolean("AllowAnimation", playerData.animationData.enabled());
PacketHandler.Instance.sendToPlayer(
new UpdateAnimationsPacket(data, player.getCommandSenderName()),
(EntityPlayerMP) player
);
}
playingAbilityAnimation = false;
}
@@ -85,6 +85,7 @@ import noppes.npcs.DataInventory;
import noppes.npcs.DataStats;
import noppes.npcs.EventHooks;
import noppes.npcs.IChatMessages;
import noppes.npcs.LogWriter;
import noppes.npcs.NBTTags;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.NoppesUtilServer;
@@ -482,8 +483,42 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
abilities.tick();
}
// DEBUG: Log client-side health state every tick to diagnose DI green health spam
if (worldObj.isRemote && ticksExisted % 20 == 0) {
float h = getHealth();
float mh = (float) getMaxHealth();
int flags = dataWatcher.getWatchableObjectInt(15);
boolean killed = isKilled();
LogWriter.info("[CLIENT-HEALTH-DEBUG] NPC=" + display.name
+ " id=" + getEntityId()
+ " health=" + h
+ " maxHealth=" + mh
+ " flags=" + Integer.toBinaryString(flags)
+ " isKilled=" + killed
+ " wasKilled=" + wasKilled
+ " isDead=" + isDead
+ " deathTime=" + deathTime
+ " statsMaxHP=" + stats.maxHealth
+ " tick=" + ticksExisted);
}
if (wasKilled != isKilled() && wasKilled) {
reset();
if (!worldObj.isRemote) {
reset();
} else {
// Client: only reset visual state. Health/flags are synced via DataWatcher.
// Full reset() on client can cause health oscillation when maxHealth is desynced.
LogWriter.info("[CLIENT-RESET-DEBUG] NPC=" + display.name
+ " id=" + getEntityId()
+ " health=" + getHealth()
+ " maxHealth=" + (float) getMaxHealth()
+ " wasKilled=" + wasKilled
+ " isKilled=" + isKilled()
+ " tick=" + ticksExisted);
deathTime = 0;
currentAnimation = EnumAnimation.NONE;
updateHitbox();
}
}
wasKilled = isKilled();
@@ -1881,6 +1916,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
readSpawnData(ByteBufUtils.readNBT(buf));
} catch (IOException e) {
if (this.worldObj != null && this.worldObj.isRemote) {
LogWriter.info("[SPAWN-DATA-DEBUG] ByteBuf readSpawnData FAILED for id=" + getEntityId()
+ " health=" + getHealth()
+ " maxHealth=" + (float) getMaxHealth()
+ " statsMaxHP=" + stats.maxHealth);
RequestProperSpawnData.reportMissingData(this);
}
}
@@ -1888,8 +1927,17 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
public void readSpawnData(NBTTagCompound compound) {
if (this.worldObj != null && this.worldObj.isRemote) {
if(requestClientFix(compound))
if(requestClientFix(compound)) {
LogWriter.info("[SPAWN-DATA-DEBUG] requestClientFix returned true (bad compound) for id=" + getEntityId()
+ " health=" + getHealth()
+ " maxHealth=" + (float) getMaxHealth()
+ " statsMaxHP=" + stats.maxHealth);
return;
}
LogWriter.info("[SPAWN-DATA-DEBUG] readSpawnData SUCCESS for id=" + getEntityId()
+ " health=" + getHealth()
+ " oldMaxHP=" + (float) getMaxHealth()
+ " newMaxHP=" + compound.getDouble("MaxHealth"));
}
stats.maxHealth = compound.getDouble("MaxHealth");