mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-04 04:32:57 +08:00
Refactor excel datas (Mainly item data)
This commit is contained in:
parent
c0418067d6
commit
f15262dd3e
@ -1,24 +1,16 @@
|
|||||||
package emu.grasscutter.data.common;
|
package emu.grasscutter.data.common;
|
||||||
|
|
||||||
import java.util.List;
|
import emu.grasscutter.game.props.ItemUseOp;
|
||||||
|
|
||||||
public class ItemUseData {
|
public class ItemUseData {
|
||||||
private String useOp;
|
private ItemUseOp useOp;
|
||||||
private List<String> useParam;
|
private String[] useParam;
|
||||||
|
|
||||||
public String getUseOp() {
|
public ItemUseOp getUseOp() {
|
||||||
return useOp;
|
return useOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseOp(String useOp) {
|
public String[] getUseParam() {
|
||||||
this.useOp = useOp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getUseParam() {
|
|
||||||
return useParam;
|
return useParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseParam(List<String> useParam) {
|
|
||||||
this.useParam = useParam;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,8 @@ public class AvatarSkillData extends GameResource {
|
|||||||
private boolean isAttackCameraLock;
|
private boolean isAttackCameraLock;
|
||||||
private int proudSkillGroupId;
|
private int proudSkillGroupId;
|
||||||
private ElementType costElemType;
|
private ElementType costElemType;
|
||||||
private List<Float> lockWeightParams;
|
|
||||||
|
|
||||||
private long nameTextMapHash;
|
private long nameTextMapHash;
|
||||||
|
|
||||||
private String abilityName;
|
private String abilityName;
|
||||||
private String lockShape;
|
|
||||||
private String globalValueKey;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(){
|
public int getId(){
|
||||||
@ -58,10 +53,6 @@ public class AvatarSkillData extends GameResource {
|
|||||||
return costElemType;
|
return costElemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Float> getLockWeightParams() {
|
|
||||||
return lockWeightParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNameTextMapHash() {
|
public long getNameTextMapHash() {
|
||||||
return nameTextMapHash;
|
return nameTextMapHash;
|
||||||
}
|
}
|
||||||
@ -69,14 +60,6 @@ public class AvatarSkillData extends GameResource {
|
|||||||
public String getAbilityName() {
|
public String getAbilityName() {
|
||||||
return abilityName;
|
return abilityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLockShape() {
|
|
||||||
return lockShape;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGlobalValueKey() {
|
|
||||||
return globalValueKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
@ -13,10 +13,8 @@ public class GadgetData extends GameResource {
|
|||||||
private boolean isInteractive;
|
private boolean isInteractive;
|
||||||
private String[] tags;
|
private String[] tags;
|
||||||
private String itemJsonName;
|
private String itemJsonName;
|
||||||
private String inteeIconName;
|
|
||||||
private long nameTextMapHash;
|
private long nameTextMapHash;
|
||||||
private int campID;
|
private int campID;
|
||||||
private String LODPatternName;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@ -43,10 +41,6 @@ public class GadgetData extends GameResource {
|
|||||||
return itemJsonName;
|
return itemJsonName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInteeIconName() {
|
|
||||||
return inteeIconName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNameTextMapHash() {
|
public long getNameTextMapHash() {
|
||||||
return nameTextMapHash;
|
return nameTextMapHash;
|
||||||
}
|
}
|
||||||
@ -55,8 +49,6 @@ public class GadgetData extends GameResource {
|
|||||||
return campID;
|
return campID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLODPatternName() { return LODPatternName; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package emu.grasscutter.data.excels;
|
package emu.grasscutter.data.excels;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
@ -8,6 +9,7 @@ import emu.grasscutter.data.ResourceType;
|
|||||||
import emu.grasscutter.data.common.ItemUseData;
|
import emu.grasscutter.data.common.ItemUseData;
|
||||||
import emu.grasscutter.game.inventory.*;
|
import emu.grasscutter.game.inventory.*;
|
||||||
import emu.grasscutter.game.props.FightProperty;
|
import emu.grasscutter.game.props.FightProperty;
|
||||||
|
import emu.grasscutter.game.props.ItemUseTarget;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -17,103 +19,75 @@ import lombok.Getter;
|
|||||||
"ReliquaryExcelConfigData.json",
|
"ReliquaryExcelConfigData.json",
|
||||||
"HomeWorldFurnitureExcelConfigData.json"
|
"HomeWorldFurnitureExcelConfigData.json"
|
||||||
})
|
})
|
||||||
|
@Getter
|
||||||
public class ItemData extends GameResource {
|
public class ItemData extends GameResource {
|
||||||
|
// Main
|
||||||
private int id;
|
private int id;
|
||||||
@Getter private int stackLimit = 1;
|
private int stackLimit = 1;
|
||||||
@Getter private int maxUseCount;
|
private int maxUseCount;
|
||||||
@Getter private int rankLevel;
|
private int rankLevel;
|
||||||
@Getter private String effectName;
|
private String effectName;
|
||||||
@Getter private int[] satiationParams;
|
private int rank;
|
||||||
@Getter private int rank;
|
private int weight;
|
||||||
@Getter private int weight;
|
private int gadgetId;
|
||||||
@Getter private int gadgetId;
|
|
||||||
|
|
||||||
@Getter private int[] destroyReturnMaterial;
|
private int[] destroyReturnMaterial;
|
||||||
@Getter private int[] destroyReturnMaterialCount;
|
private int[] destroyReturnMaterialCount;
|
||||||
|
|
||||||
@Getter private List<ItemUseData> itemUse;
|
|
||||||
|
|
||||||
// Food
|
// Enums
|
||||||
@Getter private String foodQuality;
|
private ItemType itemType = ItemType.ITEM_NONE;
|
||||||
@Getter private String useTarget;
|
private MaterialType materialType = MaterialType.MATERIAL_NONE;
|
||||||
private String[] iseParam;
|
private EquipType equipType = EquipType.EQUIP_NONE;
|
||||||
|
|
||||||
// String enums
|
|
||||||
private String itemType;
|
|
||||||
private String materialType;
|
|
||||||
private String equipType;
|
|
||||||
private String effectType;
|
private String effectType;
|
||||||
private String destroyRule;
|
private String destroyRule;
|
||||||
|
|
||||||
// Post load enum forms of above
|
// Food
|
||||||
private transient MaterialType materialEnumType;
|
private String foodQuality;
|
||||||
private transient ItemType itemEnumType;
|
private int[] satiationParams;
|
||||||
private transient EquipType equipEnumType;
|
|
||||||
|
// Usable item
|
||||||
|
private ItemUseTarget useTarget;
|
||||||
|
private List<ItemUseData> itemUse;
|
||||||
|
|
||||||
// Relic
|
// Relic
|
||||||
@Getter private int mainPropDepotId;
|
private int mainPropDepotId;
|
||||||
@Getter private int appendPropDepotId;
|
private int appendPropDepotId;
|
||||||
@Getter private int appendPropNum;
|
private int appendPropNum;
|
||||||
@Getter private int setId;
|
private int setId;
|
||||||
private int[] addPropLevels;
|
private int[] addPropLevels;
|
||||||
@Getter private int baseConvExp;
|
private int baseConvExp;
|
||||||
@Getter private int maxLevel;
|
private int maxLevel;
|
||||||
|
|
||||||
// Weapon
|
// Weapon
|
||||||
@Getter private int weaponPromoteId;
|
private int weaponPromoteId;
|
||||||
@Getter private int weaponBaseExp;
|
private int weaponBaseExp;
|
||||||
@Getter private int storyId;
|
private int storyId;
|
||||||
@Getter private int avatarPromoteId;
|
private int avatarPromoteId;
|
||||||
@Getter private int awakenMaterial;
|
private int awakenMaterial;
|
||||||
@Getter private int[] awakenCosts;
|
private int[] awakenCosts;
|
||||||
@Getter private int[] skillAffix;
|
private int[] skillAffix;
|
||||||
private WeaponProperty[] weaponProp;
|
private WeaponProperty[] weaponProp;
|
||||||
|
|
||||||
// Hash
|
// Hash
|
||||||
@Getter private String icon;
|
private long nameTextMapHash;
|
||||||
@Getter private long nameTextMapHash;
|
|
||||||
|
|
||||||
@Getter private IntSet addPropLevelSet;
|
|
||||||
|
|
||||||
// Furniture
|
// Furniture
|
||||||
@Getter private int comfort;
|
private int comfort;
|
||||||
@Getter private List<Integer> furnType;
|
private List<Integer> furnType;
|
||||||
@Getter private List<Integer> furnitureGadgetID;
|
private List<Integer> furnitureGadgetID;
|
||||||
@SerializedName("JFDLJGDFIGL")
|
@SerializedName("JFDLJGDFIGL")
|
||||||
@Getter private int roomSceneId;
|
private int roomSceneId;
|
||||||
|
|
||||||
|
// Custom
|
||||||
|
private transient IntSet addPropLevelSet;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(){
|
public int getId(){
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMaterialTypeString(){
|
public WeaponProperty[] getWeaponProperties() {
|
||||||
return this.materialType;
|
return this.weaponProp;
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getUseParam(){
|
|
||||||
return this.iseParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItemTypeString(){
|
|
||||||
return this.itemType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeaponProperty[] getWeaponProperties() {
|
|
||||||
return weaponProp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemType getItemType() {
|
|
||||||
return this.itemEnumType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MaterialType getMaterialType() {
|
|
||||||
return this.materialEnumType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EquipType getEquipType() {
|
|
||||||
return this.equipEnumType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAddRelicProp(int level) {
|
public boolean canAddRelicProp(int level) {
|
||||||
@ -121,48 +95,37 @@ public class ItemData extends GameResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEquip() {
|
public boolean isEquip() {
|
||||||
return this.itemEnumType == ItemType.ITEM_RELIQUARY || this.itemEnumType == ItemType.ITEM_WEAPON;
|
return this.itemType == ItemType.ITEM_RELIQUARY || this.itemType == ItemType.ITEM_WEAPON;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
this.itemEnumType = ItemType.getTypeByName(getItemTypeString());
|
if (this.itemType == ItemType.ITEM_RELIQUARY) {
|
||||||
this.materialEnumType = MaterialType.getTypeByName(getMaterialTypeString());
|
|
||||||
|
|
||||||
if (this.itemEnumType == ItemType.ITEM_RELIQUARY) {
|
|
||||||
this.equipEnumType = EquipType.getTypeByName(this.equipType);
|
|
||||||
if (this.addPropLevels != null && this.addPropLevels.length > 0) {
|
if (this.addPropLevels != null && this.addPropLevels.length > 0) {
|
||||||
this.addPropLevelSet = new IntOpenHashSet(this.addPropLevels);
|
this.addPropLevelSet = new IntOpenHashSet(this.addPropLevels);
|
||||||
}
|
}
|
||||||
} else if (this.itemEnumType == ItemType.ITEM_WEAPON) {
|
} else if (this.itemType == ItemType.ITEM_WEAPON) {
|
||||||
this.equipEnumType = EquipType.EQUIP_WEAPON;
|
this.equipType = EquipType.EQUIP_WEAPON;
|
||||||
} else {
|
} else {
|
||||||
this.equipEnumType = EquipType.EQUIP_NONE;
|
this.equipType = EquipType.EQUIP_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getWeaponProperties() != null) {
|
if (this.weaponProp != null) {
|
||||||
for (WeaponProperty weaponProperty : this.getWeaponProperties()) {
|
this.weaponProp = Arrays.stream(this.weaponProp).filter(prop -> prop.getPropType() != null).toArray(WeaponProperty[]::new);
|
||||||
weaponProperty.onLoad();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getFurnType() != null){
|
if (this.getFurnType() != null) {
|
||||||
this.furnType = this.furnType.stream().filter(x -> x > 0).toList();
|
this.furnType = this.furnType.stream().filter(x -> x > 0).toList();
|
||||||
}
|
}
|
||||||
if(this.getFurnitureGadgetID() != null){
|
if (this.getFurnitureGadgetID() != null) {
|
||||||
this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList();
|
this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
public static class WeaponProperty {
|
public static class WeaponProperty {
|
||||||
@Getter private FightProperty fightProp;
|
private FightProperty propType;
|
||||||
@Getter private String propType;
|
private float initValue;
|
||||||
@Getter private float initValue;
|
private String type;
|
||||||
@Getter private String type;
|
|
||||||
|
|
||||||
public void onLoad() {
|
|
||||||
this.fightProp = FightProperty.getPropByName(propType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ public class MonsterDescribeData extends GameResource {
|
|||||||
private long nameTextMapHash;
|
private long nameTextMapHash;
|
||||||
private int titleID;
|
private int titleID;
|
||||||
private int specialNameLabID;
|
private int specialNameLabID;
|
||||||
private String icon;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@ -29,10 +28,6 @@ public class MonsterDescribeData extends GameResource {
|
|||||||
return specialNameLabID;
|
return specialNameLabID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIcon() {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ public class Avatar {
|
|||||||
WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel());
|
WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel());
|
||||||
if (curveData != null) {
|
if (curveData != null) {
|
||||||
for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) {
|
for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) {
|
||||||
this.addFightProperty(weaponProperty.getFightProp(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType()));
|
this.addFightProperty(weaponProperty.getPropType(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Weapon promotion stats
|
// Weapon promotion stats
|
||||||
|
@ -29,6 +29,7 @@ import emu.grasscutter.game.player.BasePlayerDataManager;
|
|||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.props.BattlePassMissionRefreshType;
|
import emu.grasscutter.game.props.BattlePassMissionRefreshType;
|
||||||
import emu.grasscutter.game.props.BattlePassMissionStatus;
|
import emu.grasscutter.game.props.BattlePassMissionStatus;
|
||||||
|
import emu.grasscutter.game.props.ItemUseOp;
|
||||||
import emu.grasscutter.game.props.WatcherTriggerType;
|
import emu.grasscutter.game.props.WatcherTriggerType;
|
||||||
import emu.grasscutter.net.proto.BattlePassCycleOuterClass.BattlePassCycle;
|
import emu.grasscutter.net.proto.BattlePassCycleOuterClass.BattlePassCycle;
|
||||||
import emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus;
|
import emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus;
|
||||||
@ -195,7 +196,7 @@ public class BattlePassManager extends BasePlayerDataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get possible item choices.
|
// Get possible item choices.
|
||||||
String[] choices = rewardItemData.getItemUse().get(0).getUseParam().get(0).split(",");
|
String[] choices = rewardItemData.getItemUse().get(0).getUseParam()[0].split(",");
|
||||||
if (choices.length < index) {
|
if (choices.length < index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -205,7 +206,7 @@ public class BattlePassManager extends BasePlayerDataManager {
|
|||||||
int chosenId = Integer.parseInt(choices[index - 1]);
|
int chosenId = Integer.parseInt(choices[index - 1]);
|
||||||
|
|
||||||
// For ITEM_USE_ADD_SELECT_ITEM chests, we can directly add the item specified in the chest's data.
|
// For ITEM_USE_ADD_SELECT_ITEM chests, we can directly add the item specified in the chest's data.
|
||||||
if (rewardItemData.getItemUse().get(0).getUseOp().equals("ITEM_USE_ADD_SELECT_ITEM")) {
|
if (rewardItemData.getItemUse().get(0).getUseOp() == ItemUseOp.ITEM_USE_ADD_SELECT_ITEM) {
|
||||||
GameItem rewardItem = new GameItem(GameData.getItemDataMap().get(chosenId), entry.getItemCount());
|
GameItem rewardItem = new GameItem(GameData.getItemDataMap().get(chosenId), entry.getItemCount());
|
||||||
rewardItems.add(rewardItem);
|
rewardItems.add(rewardItem);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import emu.grasscutter.game.inventory.Inventory;
|
|||||||
import emu.grasscutter.game.inventory.ItemType;
|
import emu.grasscutter.game.inventory.ItemType;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
|
import emu.grasscutter.game.props.ItemUseOp;
|
||||||
import emu.grasscutter.net.proto.RetcodeOuterClass;
|
import emu.grasscutter.net.proto.RetcodeOuterClass;
|
||||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||||
import emu.grasscutter.server.game.BaseGameSystem;
|
import emu.grasscutter.server.game.BaseGameSystem;
|
||||||
@ -55,12 +56,12 @@ public class CombineManger extends BaseGameSystem {
|
|||||||
|
|
||||||
public boolean unlockCombineDiagram(Player player, GameItem diagramItem) {
|
public boolean unlockCombineDiagram(Player player, GameItem diagramItem) {
|
||||||
// Make sure this is actually a diagram.
|
// Make sure this is actually a diagram.
|
||||||
if (!diagramItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_COMBINE")) {
|
if (diagramItem.getItemData().getItemUse().get(0).getUseOp() != ItemUseOp.ITEM_USE_UNLOCK_COMBINE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the combine item we should unlock.
|
// Determine the combine item we should unlock.
|
||||||
int combineId = Integer.parseInt(diagramItem.getItemData().getItemUse().get(0).getUseParam().get(0));
|
int combineId = Integer.parseInt(diagramItem.getItemData().getItemUse().get(0).getUseParam()[0]);
|
||||||
|
|
||||||
// Remove the diagram from the player's inventory.
|
// Remove the diagram from the player's inventory.
|
||||||
// We need to do this here, before sending CombineFormulaDataNotify, or the the combine UI won't correctly
|
// We need to do this here, before sending CombineFormulaDataNotify, or the the combine UI won't correctly
|
||||||
|
@ -8,35 +8,45 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
public enum MaterialType {
|
public enum MaterialType {
|
||||||
MATERIAL_NONE (0),
|
MATERIAL_NONE (0),
|
||||||
MATERIAL_FOOD (1),
|
MATERIAL_FOOD (1),
|
||||||
MATERIAL_QUEST (2),
|
MATERIAL_QUEST (2),
|
||||||
MATERIAL_EXCHANGE (4),
|
MATERIAL_EXCHANGE (4),
|
||||||
MATERIAL_CONSUME (5),
|
MATERIAL_CONSUME (5),
|
||||||
MATERIAL_EXP_FRUIT (6),
|
MATERIAL_EXP_FRUIT (6),
|
||||||
MATERIAL_AVATAR (7),
|
MATERIAL_AVATAR (7),
|
||||||
MATERIAL_ADSORBATE (8),
|
MATERIAL_ADSORBATE (8),
|
||||||
MATERIAL_CRICKET (9),
|
MATERIAL_CRICKET (9),
|
||||||
MATERIAL_ELEM_CRYSTAL (10),
|
MATERIAL_ELEM_CRYSTAL (10),
|
||||||
MATERIAL_WEAPON_EXP_STONE (11),
|
MATERIAL_WEAPON_EXP_STONE (11),
|
||||||
MATERIAL_CHEST (12),
|
MATERIAL_CHEST (12),
|
||||||
MATERIAL_RELIQUARY_MATERIAL (13),
|
MATERIAL_RELIQUARY_MATERIAL (13),
|
||||||
MATERIAL_AVATAR_MATERIAL (14),
|
MATERIAL_AVATAR_MATERIAL (14),
|
||||||
MATERIAL_NOTICE_ADD_HP (15),
|
MATERIAL_NOTICE_ADD_HP (15),
|
||||||
MATERIAL_SEA_LAMP (16),
|
MATERIAL_SEA_LAMP (16),
|
||||||
MATERIAL_SELECTABLE_CHEST (17),
|
MATERIAL_SELECTABLE_CHEST (17),
|
||||||
MATERIAL_FLYCLOAK (18),
|
MATERIAL_FLYCLOAK (18),
|
||||||
MATERIAL_NAMECARD (19),
|
MATERIAL_NAMECARD (19),
|
||||||
MATERIAL_TALENT (20),
|
MATERIAL_TALENT (20),
|
||||||
MATERIAL_WIDGET (21),
|
MATERIAL_WIDGET (21),
|
||||||
MATERIAL_CHEST_BATCH_USE (22),
|
MATERIAL_CHEST_BATCH_USE (22),
|
||||||
MATERIAL_FAKE_ABSORBATE (23),
|
MATERIAL_FAKE_ABSORBATE (23),
|
||||||
MATERIAL_CONSUME_BATCH_USE (24),
|
MATERIAL_CONSUME_BATCH_USE (24),
|
||||||
MATERIAL_WOOD (25),
|
MATERIAL_WOOD (25),
|
||||||
MATERIAL_FURNITURE_FORMULA (27),
|
MATERIAL_FURNITURE_FORMULA (27),
|
||||||
MATERIAL_CHANNELLER_SLAB_BUFF (28),
|
MATERIAL_CHANNELLER_SLAB_BUFF (28),
|
||||||
MATERIAL_FURNITURE_SUITE_FORMULA (29),
|
MATERIAL_FURNITURE_SUITE_FORMULA (29),
|
||||||
MATERIAL_COSTUME (30);
|
MATERIAL_COSTUME (30),
|
||||||
|
MATERIAL_HOME_SEED (31),
|
||||||
|
MATERIAL_FISH_BAIT (32),
|
||||||
|
MATERIAL_FISH_ROD (33),
|
||||||
|
MATERIAL_SUMO_BUFF (34),
|
||||||
|
MATERIAL_FIREWORKS (35),
|
||||||
|
MATERIAL_BGM (36),
|
||||||
|
MATERIAL_SPICE_FOOD (37),
|
||||||
|
MATERIAL_ACTIVITY_ROBOT (38),
|
||||||
|
MATERIAL_ACTIVITY_GEAR (39),
|
||||||
|
MATERIAL_ACTIVITY_JIGSAW (40);
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
private static final Int2ObjectMap<MaterialType> map = new Int2ObjectOpenHashMap<>();
|
private static final Int2ObjectMap<MaterialType> map = new Int2ObjectOpenHashMap<>();
|
||||||
|
@ -13,6 +13,7 @@ import emu.grasscutter.game.inventory.GameItem;
|
|||||||
import emu.grasscutter.game.player.BasePlayerManager;
|
import emu.grasscutter.game.player.BasePlayerManager;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
|
import emu.grasscutter.game.props.ItemUseOp;
|
||||||
import emu.grasscutter.net.proto.CookRecipeDataOuterClass;
|
import emu.grasscutter.net.proto.CookRecipeDataOuterClass;
|
||||||
import emu.grasscutter.net.proto.PlayerCookArgsReqOuterClass.PlayerCookArgsReq;
|
import emu.grasscutter.net.proto.PlayerCookArgsReqOuterClass.PlayerCookArgsReq;
|
||||||
import emu.grasscutter.net.proto.PlayerCookReqOuterClass.PlayerCookReq;
|
import emu.grasscutter.net.proto.PlayerCookReqOuterClass.PlayerCookReq;
|
||||||
@ -47,12 +48,12 @@ public class CookingManager extends BasePlayerManager {
|
|||||||
********************/
|
********************/
|
||||||
public synchronized boolean unlockRecipe(GameItem recipeItem) {
|
public synchronized boolean unlockRecipe(GameItem recipeItem) {
|
||||||
// Make sure this is actually a cooking recipe.
|
// Make sure this is actually a cooking recipe.
|
||||||
if (!recipeItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_COOK_RECIPE")) {
|
if (recipeItem.getItemData().getItemUse().get(0).getUseOp() != ItemUseOp.ITEM_USE_UNLOCK_COOK_RECIPE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the recipe we should unlock.
|
// Determine the recipe we should unlock.
|
||||||
int recipeId = Integer.parseInt(recipeItem.getItemData().getItemUse().get(0).getUseParam().get(0));
|
int recipeId = Integer.parseInt(recipeItem.getItemData().getItemUse().get(0).getUseParam()[0]);
|
||||||
|
|
||||||
// Remove the item from the player's inventory.
|
// Remove the item from the player's inventory.
|
||||||
// We need to do this here, before sending CookRecipeDataNotify, or the the UI won't correctly update.
|
// We need to do this here, before sending CookRecipeDataNotify, or the the UI won't correctly update.
|
||||||
|
@ -6,6 +6,7 @@ import emu.grasscutter.game.home.FurnitureMakeSlotItem;
|
|||||||
import emu.grasscutter.game.inventory.GameItem;
|
import emu.grasscutter.game.inventory.GameItem;
|
||||||
import emu.grasscutter.game.player.BasePlayerManager;
|
import emu.grasscutter.game.player.BasePlayerManager;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.game.props.ItemUseOp;
|
||||||
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||||
import emu.grasscutter.server.packet.send.*;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
@ -34,18 +35,19 @@ public class FurnitureManager extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean unlockFurnitureOrSuite(GameItem useItem) {
|
public synchronized boolean unlockFurnitureOrSuite(GameItem useItem) {
|
||||||
|
ItemUseOp itemUseOp = useItem.getItemData().getItemUse().get(0).getUseOp();
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
if (!List.of("ITEM_USE_UNLOCK_FURNITURE_FORMULA", "ITEM_USE_UNLOCK_FURNITURE_SUITE")
|
if (itemUseOp != ItemUseOp.ITEM_USE_UNLOCK_FURNITURE_SUITE && itemUseOp != ItemUseOp.ITEM_USE_UNLOCK_FURNITURE_FORMULA) {
|
||||||
.contains(useItem.getItemData().getItemUse().get(0).getUseOp())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int furnitureIdOrSuiteId = Integer.parseInt(useItem.getItemData().getItemUse().get(0).getUseParam().get(0));
|
int furnitureIdOrSuiteId = Integer.parseInt(useItem.getItemData().getItemUse().get(0).getUseParam()[0]);
|
||||||
|
|
||||||
// Remove first
|
// Remove first
|
||||||
player.getInventory().removeItem(useItem, 1);
|
player.getInventory().removeItem(useItem, 1);
|
||||||
|
|
||||||
if ("ITEM_USE_UNLOCK_FURNITURE_FORMULA".equals(useItem.getItemData().getItemUse().get(0).getUseOp())) {
|
if (useItem.getItemData().getItemUse().get(0).getUseOp() == ItemUseOp.ITEM_USE_UNLOCK_FURNITURE_FORMULA) {
|
||||||
player.getUnlockedFurniture().add(furnitureIdOrSuiteId);
|
player.getUnlockedFurniture().add(furnitureIdOrSuiteId);
|
||||||
notifyUnlockFurniture();
|
notifyUnlockFurniture();
|
||||||
}else {
|
}else {
|
||||||
|
@ -14,6 +14,7 @@ import emu.grasscutter.game.inventory.GameItem;
|
|||||||
import emu.grasscutter.game.player.BasePlayerManager;
|
import emu.grasscutter.game.player.BasePlayerManager;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
|
import emu.grasscutter.game.props.ItemUseOp;
|
||||||
import emu.grasscutter.game.props.WatcherTriggerType;
|
import emu.grasscutter.game.props.WatcherTriggerType;
|
||||||
import emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData;
|
import emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData;
|
||||||
import emu.grasscutter.net.proto.ForgeQueueManipulateReqOuterClass.ForgeQueueManipulateReq;
|
import emu.grasscutter.net.proto.ForgeQueueManipulateReqOuterClass.ForgeQueueManipulateReq;
|
||||||
@ -39,12 +40,12 @@ public class ForgingManager extends BasePlayerManager {
|
|||||||
**********/
|
**********/
|
||||||
public synchronized boolean unlockForgingBlueprint(GameItem blueprintItem) {
|
public synchronized boolean unlockForgingBlueprint(GameItem blueprintItem) {
|
||||||
// Make sure this is actually a forging blueprint.
|
// Make sure this is actually a forging blueprint.
|
||||||
if (!blueprintItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_FORGE")) {
|
if (blueprintItem.getItemData().getItemUse().get(0).getUseOp() != ItemUseOp.ITEM_USE_UNLOCK_FORGE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the forging item we should unlock.
|
// Determine the forging item we should unlock.
|
||||||
int forgeId = Integer.parseInt(blueprintItem.getItemData().getItemUse().get(0).getUseParam().get(0));
|
int forgeId = Integer.parseInt(blueprintItem.getItemData().getItemUse().get(0).getUseParam()[0]);
|
||||||
|
|
||||||
// Remove the blueprint from the player's inventory.
|
// Remove the blueprint from the player's inventory.
|
||||||
// We need to do this here, before sending ForgeFormulaDataNotify, or the the forging UI won't correctly
|
// We need to do this here, before sending ForgeFormulaDataNotify, or the the forging UI won't correctly
|
||||||
|
72
src/main/java/emu/grasscutter/game/props/ItemUseOp.java
Normal file
72
src/main/java/emu/grasscutter/game/props/ItemUseOp.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package emu.grasscutter.game.props;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
|
public enum ItemUseOp {
|
||||||
|
ITEM_USE_NONE (0),
|
||||||
|
ITEM_USE_ACCEPT_QUEST (1),
|
||||||
|
ITEM_USE_TRIGGER_ABILITY (2),
|
||||||
|
ITEM_USE_GAIN_AVATAR (3),
|
||||||
|
ITEM_USE_ADD_EXP (4),
|
||||||
|
ITEM_USE_RELIVE_AVATAR (5),
|
||||||
|
ITEM_USE_ADD_BIG_TALENT_POINT (6),
|
||||||
|
ITEM_USE_ADD_PERSIST_STAMINA (7),
|
||||||
|
ITEM_USE_ADD_TEMPORARY_STAMINA (8),
|
||||||
|
ITEM_USE_ADD_CUR_STAMINA (9),
|
||||||
|
ITEM_USE_ADD_CUR_HP (10),
|
||||||
|
ITEM_USE_ADD_ELEM_ENERGY (11),
|
||||||
|
ITEM_USE_ADD_ALL_ENERGY (12),
|
||||||
|
ITEM_USE_ADD_DUNGEON_COND_TIME (13),
|
||||||
|
ITEM_USE_ADD_WEAPON_EXP (14),
|
||||||
|
ITEM_USE_ADD_SERVER_BUFF (15),
|
||||||
|
ITEM_USE_DEL_SERVER_BUFF (16),
|
||||||
|
ITEM_USE_UNLOCK_COOK_RECIPE (17),
|
||||||
|
ITEM_USE_OPEN_RANDOM_CHEST (20),
|
||||||
|
ITEM_USE_MAKE_GADGET (24),
|
||||||
|
ITEM_USE_ADD_ITEM (25),
|
||||||
|
ITEM_USE_GRANT_SELECT_REWARD (26),
|
||||||
|
ITEM_USE_ADD_SELECT_ITEM (27),
|
||||||
|
ITEM_USE_GAIN_FLYCLOAK (28),
|
||||||
|
ITEM_USE_GAIN_NAME_CARD (29),
|
||||||
|
ITEM_USE_UNLOCK_PAID_BATTLE_PASS_NORMAL (30),
|
||||||
|
ITEM_USE_GAIN_CARD_PRODUCT (31),
|
||||||
|
ITEM_USE_UNLOCK_FORGE (32),
|
||||||
|
ITEM_USE_UNLOCK_COMBINE (33),
|
||||||
|
ITEM_USE_UNLOCK_CODEX (34),
|
||||||
|
ITEM_USE_CHEST_SELECT_ITEM (35),
|
||||||
|
ITEM_USE_GAIN_RESIN_CARD_PRODUCT (36),
|
||||||
|
ITEM_USE_ADD_RELIQUARY_EXP (37),
|
||||||
|
ITEM_USE_UNLOCK_FURNITURE_FORMULA (38),
|
||||||
|
ITEM_USE_UNLOCK_FURNITURE_SUITE (39),
|
||||||
|
ITEM_USE_ADD_CHANNELLER_SLAB_BUFF (40),
|
||||||
|
ITEM_USE_GAIN_COSTUME (41),
|
||||||
|
ITEM_USE_ADD_TREASURE_MAP_BONUS_REGION_FRAGMENT (42),
|
||||||
|
ITEM_USE_COMBINE_ITEM (43),
|
||||||
|
ITEM_USE_UNLOCK_HOME_MODULE (44),
|
||||||
|
ITEM_USE_UNLOCK_HOME_BGM (45),
|
||||||
|
ITEM_USE_ADD_REGIONAL_PLAY_VAR (46);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
private static final Int2ObjectMap<ItemUseOp> map = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Stream.of(values()).forEach(e -> {
|
||||||
|
map.put(e.getValue(), e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemUseOp(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemUseOp getTypeByValue(int value) {
|
||||||
|
return map.getOrDefault(value, ITEM_USE_NONE);
|
||||||
|
}
|
||||||
|
}
|
36
src/main/java/emu/grasscutter/game/props/ItemUseTarget.java
Normal file
36
src/main/java/emu/grasscutter/game/props/ItemUseTarget.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package emu.grasscutter.game.props;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
|
public enum ItemUseTarget {
|
||||||
|
ITEM_USE_TARGET_NONE (0),
|
||||||
|
ITEM_USE_TARGET_CUR_AVATAR (1),
|
||||||
|
ITEM_USE_TARGET_CUR_TEAM (2),
|
||||||
|
ITEM_USE_TARGET_SPECIFY_AVATAR (3),
|
||||||
|
ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR (4),
|
||||||
|
ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR (5);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
private static final Int2ObjectMap<ItemUseTarget> map = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Stream.of(values()).forEach(e -> {
|
||||||
|
map.put(e.getValue(), e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemUseTarget(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemUseTarget getTypeByValue(int value) {
|
||||||
|
return map.getOrDefault(value, ITEM_USE_TARGET_NONE);
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,8 @@ import emu.grasscutter.game.inventory.GameItem;
|
|||||||
import emu.grasscutter.game.inventory.ItemType;
|
import emu.grasscutter.game.inventory.ItemType;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
|
import emu.grasscutter.game.props.ItemUseOp;
|
||||||
|
import emu.grasscutter.game.props.ItemUseTarget;
|
||||||
import emu.grasscutter.game.shop.ShopChestBatchUseTable;
|
import emu.grasscutter.game.shop.ShopChestBatchUseTable;
|
||||||
import emu.grasscutter.game.shop.ShopChestTable;
|
import emu.grasscutter.game.shop.ShopChestTable;
|
||||||
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
||||||
@ -813,7 +815,7 @@ public class InventorySystem extends BaseGameSystem {
|
|||||||
// Use
|
// Use
|
||||||
switch (useItem.getItemData().getMaterialType()) {
|
switch (useItem.getItemData().getMaterialType()) {
|
||||||
case MATERIAL_FOOD:
|
case MATERIAL_FOOD:
|
||||||
if (useItem.getItemData().getUseTarget().equals("ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR")) {
|
if (useItem.getItemData().getUseTarget() == ItemUseTarget.ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR) {
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -822,7 +824,7 @@ public class InventorySystem extends BaseGameSystem {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MATERIAL_NOTICE_ADD_HP:
|
case MATERIAL_NOTICE_ADD_HP:
|
||||||
if (useItem.getItemData().getUseTarget().equals("ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR")) {
|
if (useItem.getItemData().getUseTarget() == ItemUseTarget.ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR) {
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -836,22 +838,16 @@ public class InventorySystem extends BaseGameSystem {
|
|||||||
if (useItem.getItemData().getItemUse() == null) {
|
if (useItem.getItemData().getItemUse() == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle forging blueprints.
|
ItemUseOp useOp = useItem.getItemData().getItemUse().get(0).getUseOp();
|
||||||
if (useItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_FORGE")) {
|
|
||||||
// Unlock.
|
// Unlock item based on use operation
|
||||||
useSuccess = player.getForgingManager().unlockForgingBlueprint(useItem);
|
useSuccess = switch (useOp) {
|
||||||
}
|
case ITEM_USE_UNLOCK_FORGE -> player.getForgingManager().unlockForgingBlueprint(useItem);
|
||||||
// Handle combine diagrams.
|
case ITEM_USE_UNLOCK_COMBINE -> player.getServer().getCombineSystem().unlockCombineDiagram(player, useItem);
|
||||||
if (useItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_COMBINE")) {
|
case ITEM_USE_UNLOCK_COOK_RECIPE -> player.getCookingManager().unlockRecipe(useItem);
|
||||||
// Unlock.
|
default -> useSuccess;
|
||||||
useSuccess = player.getServer().getCombineSystem().unlockCombineDiagram(player, useItem);
|
};
|
||||||
}
|
|
||||||
// Handle cooking recipies.
|
|
||||||
if (useItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_COOK_RECIPE")) {
|
|
||||||
// Unlock.
|
|
||||||
useSuccess = player.getCookingManager().unlockRecipe(useItem);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MATERIAL_FURNITURE_FORMULA:
|
case MATERIAL_FURNITURE_FORMULA:
|
||||||
case MATERIAL_FURNITURE_SUITE_FORMULA:
|
case MATERIAL_FURNITURE_SUITE_FORMULA:
|
||||||
|
Loading…
Reference in New Issue
Block a user