9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-04 15:41:38 +00:00

Merge branch 'Xiao-MoMi:dev' into dev

This commit is contained in:
jhqwqmc
2025-11-20 10:22:23 +08:00
committed by GitHub
3 changed files with 40 additions and 21 deletions

View File

@@ -47,6 +47,7 @@ public class ItemSettings {
Color dyeColor;
@Nullable
Color fireworkColor;
Map<CustomDataType<?>, Object> customData = new IdentityHashMap<>(4);
private ItemSettings() {}
@@ -108,6 +109,7 @@ public class ItemSettings {
newSettings.dyeColor = settings.dyeColor;
newSettings.fireworkColor = settings.fireworkColor;
newSettings.ingredientSubstitutes = settings.ingredientSubstitutes;
newSettings.customData = settings.customData;
return newSettings;
}
@@ -123,73 +125,86 @@ public class ItemSettings {
return settings;
}
@SuppressWarnings("unchecked")
public <T> T getCustomData(CustomDataType<T> type) {
return (T) this.customData.get(type);
}
public void clearCustomData() {
this.customData.clear();
}
public <T> void addCustomData(CustomDataType<T> key, T value) {
this.customData.put(key, value);
}
public ProjectileMeta projectileMeta() {
return projectileMeta;
return this.projectileMeta;
}
public boolean disableVanillaBehavior() {
return disableVanillaBehavior;
return this.disableVanillaBehavior;
}
public Repairable repairable() {
return repairable;
return this.repairable;
}
public int fuelTime() {
return fuelTime;
return this.fuelTime;
}
public boolean renameable() {
return renameable;
return this.renameable;
}
public Set<Key> tags() {
return tags;
return this.tags;
}
public Tristate dyeable() {
return dyeable;
return this.dyeable;
}
public boolean canEnchant() {
return canEnchant;
return this.canEnchant;
}
public List<AnvilRepairItem> repairItems() {
return anvilRepairItems;
return this.anvilRepairItems;
}
public boolean respectRepairableComponent() {
return respectRepairableComponent;
return this.respectRepairableComponent;
}
public List<Key> ingredientSubstitutes() {
return ingredientSubstitutes;
return this.ingredientSubstitutes;
}
@Nullable
public FoodData foodData() {
return foodData;
return this.foodData;
}
@Nullable
public Key consumeReplacement() {
return consumeReplacement;
return this.consumeReplacement;
}
@Nullable
public CraftRemainder craftRemainder() {
return craftRemainder;
return this.craftRemainder;
}
@Nullable
public Helmet helmet() {
return helmet;
return this.helmet;
}
@Nullable
public ItemEquipment equipment() {
return equipment;
return this.equipment;
}
@Nullable
@@ -203,11 +218,11 @@ public class ItemSettings {
}
public List<DamageSource> invulnerable() {
return invulnerable;
return this.invulnerable;
}
public float compostProbability() {
return compostProbability;
return this.compostProbability;
}
public ItemSettings fireworkColor(Color color) {
@@ -482,7 +497,7 @@ public class ItemSettings {
registerFactory("ingredient-substitute", (value -> settings -> settings.ingredientSubstitutes(MiscUtils.getAsStringList(value).stream().map(Key::of).toList())));
}
private static void registerFactory(String id, ItemSettings.Modifier.Factory factory) {
public static void registerFactory(String id, ItemSettings.Modifier.Factory factory) {
FACTORIES.put(id, factory);
}
}

View File

@@ -52,11 +52,11 @@ public class TemplateManagerImpl implements TemplateManager {
@Override
public void parseObject(Pack pack, Path path, String node, Key id, Object obj) {
if (templates.containsKey(id)) {
if (TemplateManagerImpl.this.templates.containsKey(id)) {
throw new LocalizedResourceConfigException("warning.config.template.duplicate");
}
// 预处理会将 string类型的键或值解析为ArgumentString以加速模板应用。所以处理后不可能存在String类型。
templates.put(id, preprocessUnknownValue(obj));
TemplateManagerImpl.this.templates.put(id, preprocessUnknownValue(obj));
}
}

View File

@@ -0,0 +1,4 @@
package net.momirealms.craftengine.core.util;
public class CustomDataType<T> {
}