mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 01:15:52 +01:00
Implement the Home System (Serenitea Pot)
This commit is contained in:
@@ -7,12 +7,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.binout.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import emu.grasscutter.data.binout.AbilityEmbryoEntry;
|
||||
import emu.grasscutter.data.binout.AbilityModifierEntry;
|
||||
import emu.grasscutter.data.binout.MainQuestData;
|
||||
import emu.grasscutter.data.binout.OpenConfigEntry;
|
||||
import emu.grasscutter.data.binout.ScenePointEntry;
|
||||
import emu.grasscutter.data.excels.*;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
@@ -28,7 +24,9 @@ public class GameData {
|
||||
private static final Map<String, OpenConfigEntry> openConfigEntries = new HashMap<>();
|
||||
private static final Map<String, ScenePointEntry> scenePointEntries = new HashMap<>();
|
||||
private static final Int2ObjectMap<MainQuestData> mainQuestData = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
|
||||
private static final Int2ObjectMap<HomeworldDefaultSaveData> homeworldDefaultSaveData = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// ExcelConfigs
|
||||
private static final Int2ObjectMap<PlayerLevelData> playerLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@@ -140,7 +138,9 @@ public class GameData {
|
||||
public static Int2ObjectMap<MainQuestData> getMainQuestDataMap() {
|
||||
return mainQuestData;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<HomeworldDefaultSaveData> getHomeworldDefaultSaveData() {
|
||||
return homeworldDefaultSaveData;
|
||||
}
|
||||
public static Int2ObjectMap<AvatarData> getAvatarDataMap() {
|
||||
return avatarDataMap;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package emu.grasscutter.data;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import emu.grasscutter.data.binout.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import lombok.SneakyThrows;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -15,12 +19,6 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.binout.AbilityEmbryoEntry;
|
||||
import emu.grasscutter.data.binout.AbilityModifier;
|
||||
import emu.grasscutter.data.binout.AbilityModifierEntry;
|
||||
import emu.grasscutter.data.binout.MainQuestData;
|
||||
import emu.grasscutter.data.binout.OpenConfigEntry;
|
||||
import emu.grasscutter.data.binout.ScenePointEntry;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityConfigData;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierActionType;
|
||||
@@ -66,6 +64,40 @@ public class ResourceLoader {
|
||||
loadQuests();
|
||||
// Load scene points - must be done AFTER resources are loaded
|
||||
loadScenePoints();
|
||||
|
||||
// Load default home layout
|
||||
loadHomeworldDefaultSaveData();
|
||||
// Custom - TODO move this somewhere else
|
||||
try {
|
||||
GameData.getAvatarSkillDepotDataMap().get(504).setAbilities(
|
||||
new AbilityEmbryoEntry(
|
||||
"",
|
||||
new String[] {
|
||||
"Avatar_PlayerBoy_ExtraAttack_Wind",
|
||||
"Avatar_Player_UziExplode_Mix",
|
||||
"Avatar_Player_UziExplode",
|
||||
"Avatar_Player_UziExplode_Strike_01",
|
||||
"Avatar_Player_UziExplode_Strike_02",
|
||||
"Avatar_Player_WindBreathe",
|
||||
"Avatar_Player_WindBreathe_CameraController"
|
||||
}
|
||||
));
|
||||
GameData.getAvatarSkillDepotDataMap().get(704).setAbilities(
|
||||
new AbilityEmbryoEntry(
|
||||
"",
|
||||
new String[] {
|
||||
"Avatar_PlayerGirl_ExtraAttack_Wind",
|
||||
"Avatar_Player_UziExplode_Mix",
|
||||
"Avatar_Player_UziExplode",
|
||||
"Avatar_Player_UziExplode_Strike_01",
|
||||
"Avatar_Player_UziExplode_Strike_02",
|
||||
"Avatar_Player_WindBreathe",
|
||||
"Avatar_Player_WindBreathe_CameraController"
|
||||
}
|
||||
));
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Error loading abilities", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadResources() {
|
||||
@@ -394,6 +426,26 @@ public class ResourceLoader {
|
||||
Grasscutter.getLogger().info("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas.");
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static void loadHomeworldDefaultSaveData(){
|
||||
var folder = Files.list(Path.of(RESOURCE("BinOutput/HomeworldDefaultSave"))).toList();
|
||||
var pattern = Pattern.compile("scene(.*)_home_config.json");
|
||||
|
||||
for(var file : folder){
|
||||
var matcher = pattern.matcher(file.getFileName().toString());
|
||||
if(!matcher.find()){
|
||||
continue;
|
||||
}
|
||||
var sceneId = matcher.group(1);
|
||||
|
||||
var data = Grasscutter.getGsonFactory().fromJson(Files.readString(file), HomeworldDefaultSaveData.class);
|
||||
|
||||
GameData.getHomeworldDefaultSaveData().put(Integer.parseInt(sceneId), data);
|
||||
}
|
||||
|
||||
Grasscutter.getLogger().info("Loaded " + GameData.getHomeworldDefaultSaveData().size() + " HomeworldDefaultSaveDatas.");
|
||||
}
|
||||
|
||||
// BinOutput configs
|
||||
|
||||
public static class AvatarConfig {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package emu.grasscutter.data.binout;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public class HomeworldDefaultSaveData {
|
||||
|
||||
@SerializedName(value = "KFHBFNPDJBE", alternate = "PKACPHDGGEI")
|
||||
List<HomeBlock> homeBlockLists;
|
||||
@SerializedName(value = "IJNPADKGNKE", alternate = "MINCKHBNING")
|
||||
Position bornPos;
|
||||
@SerializedName("IPIIGEMFLHK")
|
||||
Position bornRot;
|
||||
@SerializedName("HHOLBNPIHEM")
|
||||
Position djinPos;
|
||||
@SerializedName("KNHCJKHCOAN")
|
||||
HomeFurniture mainhouse;
|
||||
|
||||
@SerializedName("NIHOJFEKFPG")
|
||||
List<HomeFurniture> doorLists;
|
||||
@SerializedName("EPGELGEFJFK")
|
||||
List<HomeFurniture> stairLists;
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public static class HomeBlock{
|
||||
|
||||
@SerializedName(value = "FGIJCELCGFI", alternate = "PGDPDIDJEEL")
|
||||
int blockId;
|
||||
|
||||
@SerializedName(value = "BEAPOFELABD", alternate = "MLIODLGDFHJ")
|
||||
List<HomeFurniture> furnitures;
|
||||
}
|
||||
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public static class HomeFurniture{
|
||||
|
||||
@SerializedName(value = "ENHNGKJBJAB", alternate = "KMAAJJHPNBA")
|
||||
int id;
|
||||
@SerializedName(value = "NGIEEIOLPPO", alternate = "JFKAHNCPDME")
|
||||
Position pos;
|
||||
//@SerializedName(value = "HEOCEHKEBFM", alternate = "LKCKOOGFDBM")
|
||||
Position rot;
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,20 @@ package emu.grasscutter.data.excels;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import emu.grasscutter.data.common.ItemUseData;
|
||||
import emu.grasscutter.game.inventory.*;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
@ResourceType(name = {"MaterialExcelConfigData.json", "WeaponExcelConfigData.json", "ReliquaryExcelConfigData.json"})
|
||||
@ResourceType(name = {"MaterialExcelConfigData.json",
|
||||
"WeaponExcelConfigData.json",
|
||||
"ReliquaryExcelConfigData.json",
|
||||
"HomeWorldFurnitureExcelConfigData.json"
|
||||
})
|
||||
public class ItemData extends GameResource {
|
||||
|
||||
private int id;
|
||||
@@ -63,12 +69,19 @@ public class ItemData extends GameResource {
|
||||
private long nameTextMapHash;
|
||||
|
||||
// Post load
|
||||
private transient emu.grasscutter.game.inventory.MaterialType materialEnumType;
|
||||
private transient emu.grasscutter.game.inventory.ItemType itemEnumType;
|
||||
private transient emu.grasscutter.game.inventory.EquipType equipEnumType;
|
||||
private transient MaterialType materialEnumType;
|
||||
private transient ItemType itemEnumType;
|
||||
private transient EquipType equipEnumType;
|
||||
|
||||
private IntSet addPropLevelSet;
|
||||
|
||||
|
||||
// Furniture
|
||||
private int comfort;
|
||||
private List<Integer> furnType;
|
||||
private List<Integer> furnitureGadgetID;
|
||||
@SerializedName("JFDLJGDFIGL")
|
||||
private int roomSceneId;
|
||||
|
||||
@Override
|
||||
public int getId(){
|
||||
return this.id;
|
||||
@@ -193,41 +206,57 @@ public class ItemData extends GameResource {
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public emu.grasscutter.game.inventory.ItemType getItemType() {
|
||||
|
||||
public int getComfort() {
|
||||
return comfort;
|
||||
}
|
||||
|
||||
public List<Integer> getFurnType() {
|
||||
return furnType;
|
||||
}
|
||||
|
||||
public List<Integer> getFurnitureGadgetID() {
|
||||
return furnitureGadgetID;
|
||||
}
|
||||
|
||||
public int getRoomSceneId() {
|
||||
return roomSceneId;
|
||||
}
|
||||
|
||||
public ItemType getItemType() {
|
||||
return this.itemEnumType;
|
||||
}
|
||||
|
||||
public emu.grasscutter.game.inventory.MaterialType getMaterialType() {
|
||||
public MaterialType getMaterialType() {
|
||||
return this.materialEnumType;
|
||||
}
|
||||
|
||||
public emu.grasscutter.game.inventory.EquipType getEquipType() {
|
||||
public EquipType getEquipType() {
|
||||
return this.equipEnumType;
|
||||
}
|
||||
|
||||
public boolean canAddRelicProp(int level) {
|
||||
return this.addPropLevelSet != null & this.addPropLevelSet.contains(level);
|
||||
return this.addPropLevelSet != null && this.addPropLevelSet.contains(level);
|
||||
}
|
||||
|
||||
public boolean isEquip() {
|
||||
return this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_RELIQUARY || this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_WEAPON;
|
||||
return this.itemEnumType == ItemType.ITEM_RELIQUARY || this.itemEnumType == ItemType.ITEM_WEAPON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.itemEnumType = emu.grasscutter.game.inventory.ItemType.getTypeByName(getItemTypeString());
|
||||
this.materialEnumType = emu.grasscutter.game.inventory.MaterialType.getTypeByName(getMaterialTypeString());
|
||||
this.itemEnumType = ItemType.getTypeByName(getItemTypeString());
|
||||
this.materialEnumType = MaterialType.getTypeByName(getMaterialTypeString());
|
||||
|
||||
if (this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_RELIQUARY) {
|
||||
this.equipEnumType = emu.grasscutter.game.inventory.EquipType.getTypeByName(this.equipType);
|
||||
if (this.itemEnumType == ItemType.ITEM_RELIQUARY) {
|
||||
this.equipEnumType = EquipType.getTypeByName(this.equipType);
|
||||
if (this.addPropLevels != null && this.addPropLevels.length > 0) {
|
||||
this.addPropLevelSet = new IntOpenHashSet(this.addPropLevels);
|
||||
}
|
||||
} else if (this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_WEAPON) {
|
||||
this.equipEnumType = emu.grasscutter.game.inventory.EquipType.EQUIP_WEAPON;
|
||||
} else if (this.itemEnumType == ItemType.ITEM_WEAPON) {
|
||||
this.equipEnumType = EquipType.EQUIP_WEAPON;
|
||||
} else {
|
||||
this.equipEnumType = emu.grasscutter.game.inventory.EquipType.EQUIP_NONE;
|
||||
this.equipEnumType = EquipType.EQUIP_NONE;
|
||||
}
|
||||
|
||||
if (this.getWeaponProperties() != null) {
|
||||
@@ -235,6 +264,13 @@ public class ItemData extends GameResource {
|
||||
weaponProperty.onLoad();
|
||||
}
|
||||
}
|
||||
|
||||
if(this.getFurnType() != null){
|
||||
this.furnType = this.furnType.stream().filter(x -> x > 0).toList();
|
||||
}
|
||||
if(this.getFurnitureGadgetID() != null){
|
||||
this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList();
|
||||
}
|
||||
}
|
||||
|
||||
public static class WeaponProperty {
|
||||
|
||||
Reference in New Issue
Block a user