mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-12 21:34:35 +01:00
Fix items not displaying as equipped
This commit is contained in:
@@ -6,9 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
|
|
||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.*;
|
||||||
import dev.morphia.annotations.Id;
|
|
||||||
import dev.morphia.annotations.Indexed;
|
|
||||||
import emu.lunarcore.LunarCore;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.GameDepot;
|
import emu.lunarcore.data.GameDepot;
|
||||||
@@ -54,8 +52,11 @@ public class GameItem {
|
|||||||
@Setter private int mainAffix;
|
@Setter private int mainAffix;
|
||||||
private List<GameItemSubAffix> subAffixes;
|
private List<GameItemSubAffix> subAffixes;
|
||||||
|
|
||||||
private int equipAvatar;
|
@Indexed private ObjectId equipAvatarId; // Object id of the avatar this item is equipped to
|
||||||
@Indexed private ObjectId equipAvatarId;
|
private transient GameAvatar equipAvatar;
|
||||||
|
|
||||||
|
@LoadOnly @AlsoLoad("equipAvatar")
|
||||||
|
private int equipAvatarExcelId; // Deprecated legacy field
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GameItem() {
|
public GameItem() {
|
||||||
@@ -153,11 +154,13 @@ public class GameItem {
|
|||||||
public boolean setEquipAvatar(GameAvatar avatar) {
|
public boolean setEquipAvatar(GameAvatar avatar) {
|
||||||
if (avatar == null && this.isEquipped()) {
|
if (avatar == null && this.isEquipped()) {
|
||||||
this.equipAvatarId = null;
|
this.equipAvatarId = null;
|
||||||
this.equipAvatar = 0;
|
this.equipAvatar = null;
|
||||||
|
this.equipAvatarExcelId = 0; // Legacy field
|
||||||
return true;
|
return true;
|
||||||
} else if (this.equipAvatarId != avatar.getId()) {
|
} else if (this.equipAvatarId != avatar.getId()) {
|
||||||
this.equipAvatarId = avatar.getId();
|
this.equipAvatarId = avatar.getId();
|
||||||
this.equipAvatar = 0;
|
this.equipAvatar = avatar;
|
||||||
|
this.equipAvatarExcelId = 0; // Legacy field
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,9 +290,12 @@ public class GameItem {
|
|||||||
.setExp(this.getExp())
|
.setExp(this.getExp())
|
||||||
.setIsProtected(this.isLocked())
|
.setIsProtected(this.isLocked())
|
||||||
.setIsDiscarded(this.isDiscarded())
|
.setIsDiscarded(this.isDiscarded())
|
||||||
.setBaseAvatarId(this.getEquipAvatar())
|
|
||||||
.setEquipAvatarId(this.getEquipAvatar())
|
|
||||||
.setMainAffixId(this.mainAffix);
|
.setMainAffixId(this.mainAffix);
|
||||||
|
|
||||||
|
if (this.getEquipAvatar() != null) {
|
||||||
|
proto.setBaseAvatarId(this.getEquipAvatar().getAvatarId());
|
||||||
|
proto.setEquipAvatarId(this.getEquipAvatar().getAvatarId());
|
||||||
|
}
|
||||||
|
|
||||||
if (this.subAffixes != null) {
|
if (this.subAffixes != null) {
|
||||||
for (var subAffix : this.subAffixes) {
|
for (var subAffix : this.subAffixes) {
|
||||||
@@ -308,9 +314,12 @@ public class GameItem {
|
|||||||
.setExp(this.getExp())
|
.setExp(this.getExp())
|
||||||
.setIsProtected(this.isLocked())
|
.setIsProtected(this.isLocked())
|
||||||
.setPromotion(this.getPromotion())
|
.setPromotion(this.getPromotion())
|
||||||
.setRank(this.getRank())
|
.setRank(this.getRank());
|
||||||
.setBaseAvatarId(this.getEquipAvatar())
|
|
||||||
.setEquipAvatarId(this.getEquipAvatar());
|
if (this.getEquipAvatar() != null) {
|
||||||
|
proto.setBaseAvatarId(this.getEquipAvatar().getAvatarId());
|
||||||
|
proto.setEquipAvatarId(this.getEquipAvatar().getAvatarId());
|
||||||
|
}
|
||||||
|
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -591,13 +591,13 @@ public class Inventory extends BasePlayerManager {
|
|||||||
putItem(item, tab);
|
putItem(item, tab);
|
||||||
|
|
||||||
// Equip to a character if possible
|
// Equip to a character if possible
|
||||||
if (item.isEquipped() || item.getEquipAvatar() > 0) {
|
if (item.isEquipped() || item.getEquipAvatarExcelId() > 0) {
|
||||||
GameAvatar avatar = null;
|
GameAvatar avatar = null;
|
||||||
boolean hasEquipped = false;
|
boolean hasEquipped = false;
|
||||||
|
|
||||||
if (item.getEquipAvatar() > 0) {
|
if (item.getEquipAvatarExcelId() > 0) {
|
||||||
// Legacy equip handler
|
// Legacy equip handler
|
||||||
avatar = getPlayer().getAvatars().getAvatarById(item.getEquipAvatar());
|
avatar = getPlayer().getAvatars().getAvatarById(item.getEquipAvatarExcelId());
|
||||||
item.setEquipAvatar(avatar);
|
item.setEquipAvatar(avatar);
|
||||||
item.save();
|
item.save();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user