diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLib.java b/src/main/java/emu/grasscutter/scripts/ScriptLib.java index 7a102e1c3..e37c8be3c 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLib.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLib.java @@ -527,11 +527,9 @@ public class ScriptLib { if (scriptManager == null) return 1; var scene = scriptManager.getScene(); - var entity = scene.getEntityById(entityId); - if (entity == null) return 2; - scene.broadcastPacket( - new PacketServerGlobalValueChangeNotify(entity, sgvName, value)); + scene.runWhenFinished(() -> scene.broadcastPacket( + new PacketServerGlobalValueChangeNotify(entityId, sgvName, value))); return 0; } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketServerGlobalValueChangeNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketServerGlobalValueChangeNotify.java index 58dc12f98..e1498ca91 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketServerGlobalValueChangeNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketServerGlobalValueChangeNotify.java @@ -16,4 +16,14 @@ public final class PacketServerGlobalValueChangeNotify extends BasePacket { .setValue(value) .setKeyHash(Utils.abilityHash(abilityHash))); } + + public PacketServerGlobalValueChangeNotify(int entityId, String abilityHash, int value) { + super(PacketOpcodes.ServerGlobalValueChangeNotify); + + this.setData( + ServerGlobalValueChangeNotify.newBuilder() + .setEntityId(entityId) + .setValue(value) + .setKeyHash(Utils.abilityHash(abilityHash))); + } }