Skip to content

Commit

Permalink
更新 EntityAvatar.java
Browse files Browse the repository at this point in the history
  • Loading branch information
亡灵暴龙大帝 committed Jul 3, 2024
1 parent baa5da8 commit c92c942
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,35 @@ public EntityAvatar(Scene scene, Avatar avatar) {
this.avatar = avatar;
this.avatar.setCurrentEnergy();

if (scene != null) {
var world = scene.getWorld();
this.id = world.getNextEntityId(EntityIdType.AVATAR);
this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);

var weapon = this.getAvatar().getWeapon();
GameItem 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()));
weapon.setWeaponEntity(
new EntityWeapon(this.getPlayer().getScene(), weapon.getItemData().getGadgetId()));
scene.getWeaponEntities().put(weapon.getWeaponEntity().getId(), weapon.getWeaponEntity());
}
} else {
Grasscutter.getLogger()
.error("EntityAvatar中weapon为null");
}
} else {
Grasscutter.getLogger()
.error("Unable to create EntityAvatar instance; provided scene is 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.");
// }

this.initAbilities();

Expand Down

0 comments on commit c92c942

Please sign in to comment.