mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-20 15:39:22 +00:00
修改替代配方的配置位置
This commit is contained in:
@@ -208,6 +208,15 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
for (Key tag : tags) {
|
for (Key tag : tags) {
|
||||||
this.customItemTags.computeIfAbsent(tag, k -> new ArrayList<>()).add(customItem.uniqueId());
|
this.customItemTags.computeIfAbsent(tag, k -> new ArrayList<>()).add(customItem.uniqueId());
|
||||||
}
|
}
|
||||||
|
// ingredient substitutes
|
||||||
|
List<Key> substitutes = customItem.settings().ingredientSubstitutes();
|
||||||
|
if (!substitutes.isEmpty()) {
|
||||||
|
for (Key key : substitutes) {
|
||||||
|
if (VANILLA_ITEMS.contains(key)) {
|
||||||
|
AbstractItemManager.this.ingredientSubstitutes.computeIfAbsent(key, k -> new ArrayList<>()).add(customItem.uniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -611,17 +620,6 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
AbstractItemManager.this.plugin.itemBrowserManager().addExternalCategoryMember(id, MiscUtils.getAsStringList(section.get("category")).stream().map(Key::of).toList());
|
AbstractItemManager.this.plugin.itemBrowserManager().addExternalCategoryMember(id, MiscUtils.getAsStringList(section.get("category")).stream().map(Key::of).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 替代配方材料
|
|
||||||
if (section.containsKey("ingredient-substitute")) {
|
|
||||||
List<String> substitutes = MiscUtils.getAsStringList(section.get("ingredient-substitute"));
|
|
||||||
for (String substitute : substitutes) {
|
|
||||||
Key key = Key.of(substitute);
|
|
||||||
if (VANILLA_ITEMS.contains(key)) {
|
|
||||||
AbstractItemManager.this.ingredientSubstitutes.computeIfAbsent(key, k -> new ArrayList<>()).add(uniqueId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ========================
|
* ========================
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class ItemSettings {
|
|||||||
boolean canEnchant = true;
|
boolean canEnchant = true;
|
||||||
float compostProbability= 0.5f;
|
float compostProbability= 0.5f;
|
||||||
boolean respectRepairableComponent = false;
|
boolean respectRepairableComponent = false;
|
||||||
|
List<Key> ingredientSubstitutes = List.of();
|
||||||
@Nullable
|
@Nullable
|
||||||
ItemEquipment equipment;
|
ItemEquipment equipment;
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -104,6 +105,7 @@ public class ItemSettings {
|
|||||||
newSettings.respectRepairableComponent = settings.respectRepairableComponent;
|
newSettings.respectRepairableComponent = settings.respectRepairableComponent;
|
||||||
newSettings.dyeColor = settings.dyeColor;
|
newSettings.dyeColor = settings.dyeColor;
|
||||||
newSettings.fireworkColor = settings.fireworkColor;
|
newSettings.fireworkColor = settings.fireworkColor;
|
||||||
|
newSettings.ingredientSubstitutes = settings.ingredientSubstitutes;
|
||||||
return newSettings;
|
return newSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +161,10 @@ public class ItemSettings {
|
|||||||
return respectRepairableComponent;
|
return respectRepairableComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Key> ingredientSubstitutes() {
|
||||||
|
return ingredientSubstitutes;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public FoodData foodData() {
|
public FoodData foodData() {
|
||||||
return foodData;
|
return foodData;
|
||||||
@@ -207,6 +213,11 @@ public class ItemSettings {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemSettings ingredientSubstitutes(List<Key> substitutes) {
|
||||||
|
this.ingredientSubstitutes = substitutes;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemSettings dyeColor(Color color) {
|
public ItemSettings dyeColor(Color color) {
|
||||||
this.dyeColor = color;
|
this.dyeColor = color;
|
||||||
return this;
|
return this;
|
||||||
@@ -458,6 +469,7 @@ public class ItemSettings {
|
|||||||
}).toList();
|
}).toList();
|
||||||
return settings -> settings.invulnerable(list);
|
return settings -> settings.invulnerable(list);
|
||||||
}));
|
}));
|
||||||
|
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) {
|
private static void registerFactory(String id, ItemSettings.Modifier.Factory factory) {
|
||||||
|
|||||||
Reference in New Issue
Block a user