mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 12:42:19 +00:00
Merge branch 'dev' into syntax-highlighter-unified
This commit is contained in:
commit
bee84a622c
5 files changed
+157
-65
No files matched your search
@@ -6,6 +6,7 @@ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.controllers.AuctionController;
|
||||
@@ -78,5 +79,8 @@ public class ServerTickHandler {
|
||||
|
||||
// Save and unload the player's profile data on logout
|
||||
ProfileController.Instance.logout(event.player);
|
||||
|
||||
// Clear script session tokens
|
||||
PacketUtil.clearScriptSession(event.player);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ 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;
|
||||
@@ -273,18 +272,20 @@ public class ScriptContainer implements IScriptUnit {
|
||||
unknownFunctions.add(type);
|
||||
}
|
||||
} else {
|
||||
if (instanceBindings != null) {
|
||||
if (!this.cachedFunctions.containsKey(type)) {
|
||||
if (!this.cachedFunctions.containsKey(type)) {
|
||||
ScriptObjectMirror func;
|
||||
if (instanceBindings != null) {
|
||||
Object val = instanceBindings.get(type);
|
||||
ScriptObjectMirror func = val instanceof ScriptObjectMirror ? (ScriptObjectMirror) val : null;
|
||||
this.cachedFunctions.put(type, func);
|
||||
func = val instanceof ScriptObjectMirror ? (ScriptObjectMirror) val : null;
|
||||
} else {
|
||||
ScriptObjectMirror global = (ScriptObjectMirror) engine.getBindings(ScriptContext.ENGINE_SCOPE);
|
||||
func = (ScriptObjectMirror) global.get(type);
|
||||
}
|
||||
ScriptObjectMirror func = this.cachedFunctions.get(type);
|
||||
if (func != null) {
|
||||
func.call(null, event);
|
||||
}
|
||||
} else {
|
||||
((Invocable) engine).invokeFunction(type, event);
|
||||
this.cachedFunctions.put(type, func);
|
||||
}
|
||||
ScriptObjectMirror func = this.cachedFunctions.get(type);
|
||||
if (func != null) {
|
||||
func.call(null, event);
|
||||
}
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
|
||||
@@ -85,7 +85,6 @@ 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;
|
||||
@@ -483,42 +482,8 @@ 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) {
|
||||
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();
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
wasKilled = isKilled();
|
||||
@@ -1916,10 +1881,6 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -1927,17 +1888,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
|
||||
public void readSpawnData(NBTTagCompound compound) {
|
||||
if (this.worldObj != null && this.worldObj.isRemote) {
|
||||
if(requestClientFix(compound)) {
|
||||
LogWriter.info("[SPAWN-DATA-DEBUG] requestClientFix returned true (bad compound) for id=" + getEntityId()
|
||||
+ " health=" + getHealth()
|
||||
+ " maxHealth=" + (float) getMaxHealth()
|
||||
+ " statsMaxHP=" + stats.maxHealth);
|
||||
if(requestClientFix(compound))
|
||||
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");
|
||||
|
||||
Reference in new issue
Block a user