mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-03-12 23:58:30 +08:00
Validate EntityAvatar
scene before invoking
This commit is contained in:
parent
dd2d1dc7e2
commit
9bbdc11334
@ -1,6 +1,7 @@
|
||||
package emu.grasscutter.game.entity;
|
||||
|
||||
import emu.grasscutter.GameConstants;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.avatar.AvatarData;
|
||||
import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData;
|
||||
@ -55,11 +56,17 @@ public class EntityAvatar extends GameEntity {
|
||||
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
if (scene != null) this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);
|
||||
|
||||
GameItem weapon = this.getAvatar().getWeapon();
|
||||
if (weapon != null) {
|
||||
weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON));
|
||||
if (scene != null) {
|
||||
var world = scene.getWorld();
|
||||
this.id = world.getNextEntityId(EntityIdType.AVATAR);
|
||||
|
||||
var weapon = this.getAvatar().getWeapon();
|
||||
if (weapon != null) {
|
||||
weapon.setWeaponEntityId(world.getNextEntityId(EntityIdType.WEAPON));
|
||||
}
|
||||
} else {
|
||||
Grasscutter.getLogger().error("Unable to create EntityAvatar instance; provided scene is null.");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user