Skip to content

Commit

Permalink
开服一段时间后scene的值会变成null 暂时先观察定位这里
Browse files Browse the repository at this point in the history
  • Loading branch information
亡灵暴龙大帝 committed Jul 2, 2024
1 parent baa5da8 commit f5d81d8
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,27 @@ public EntityAvatar(Scene scene, Avatar avatar) {
this.avatar = avatar;
this.avatar.setCurrentEnergy();

if (scene != null) {
// if (scene != null) {
// var world = scene.getWorld();
// this.id = world.getNextEntityId(EntityIdType.AVATAR);
//
// var weapon = this.getAvatar().getWeapon();
// if (weapon != null) {
// if (!(weapon.getWeaponEntity() != null && weapon.getWeaponEntity().getScene() == scene)) {
// weapon.setWeaponEntity(
// new EntityWeapon(this.getPlayer().getScene(), weapon.getItemData().getGadgetId()));
// scene.getWeaponEntities().put(weapon.getWeaponEntity().getId(), weapon.getWeaponEntity());
// }
// }
// } else {
// Grasscutter.getLogger()
// .error("Unable to create EntityAvatar instance; provided scene is null. 使用默认值scene3");
// }

if (scene == null) {
Grasscutter.getLogger().error("Unable to create EntityAvatar instance; provided scene is null.");
}

var world = scene.getWorld();
this.id = world.getNextEntityId(EntityIdType.AVATAR);

Expand All @@ -61,10 +81,6 @@ public EntityAvatar(Scene scene, Avatar avatar) {
scene.getWeaponEntities().put(weapon.getWeaponEntity().getId(), weapon.getWeaponEntity());
}
}
} else {
Grasscutter.getLogger()
.error("Unable to create EntityAvatar instance; provided scene is null.");
}

this.initAbilities();

Expand Down

0 comments on commit f5d81d8

Please sign in to comment.