Send packet after scene load & Directly send back entity ID to clients

This commit is contained in:
KingRainbow44 2023-07-14 21:22:45 -04:00
parent fecf83cfa4
commit f0775f70f3
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 12 additions and 4 deletions

View File

@ -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;
}

View File

@ -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)));
}
}