mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
添加ingredient elements
This commit is contained in:
@@ -14,6 +14,8 @@ templates:
|
|||||||
slot: ${slot}
|
slot: ${slot}
|
||||||
model:
|
model:
|
||||||
template: default:model/armor_trim
|
template: default:model/armor_trim
|
||||||
|
arguments:
|
||||||
|
texture: minecraft:item/custom/topaz_${part}
|
||||||
items:
|
items:
|
||||||
default:topaz_helmet:
|
default:topaz_helmet:
|
||||||
template:
|
template:
|
||||||
|
|||||||
@@ -147,115 +147,116 @@ templates#models#2d:
|
|||||||
# arguments:
|
# arguments:
|
||||||
# material: armor material type
|
# material: armor material type
|
||||||
# part: slot type
|
# part: slot type
|
||||||
|
# texture: the texture path of the armor item
|
||||||
default:model/armor_trim:
|
default:model/armor_trim:
|
||||||
type: minecraft:select
|
type: minecraft:select
|
||||||
property: minecraft:trim_material
|
property: minecraft:trim_material
|
||||||
fallback:
|
fallback:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}
|
path: ${__NAMESPACE__}:item/${material}_${part}
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
cases:
|
cases:
|
||||||
- when: minecraft:quartz
|
- when: minecraft:quartz
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_quartz_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_quartz_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_quartz
|
layer1: minecraft:trims/items/${part}_trim_quartz
|
||||||
- when: minecraft:iron
|
- when: minecraft:iron
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_iron_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_iron_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_iron
|
layer1: minecraft:trims/items/${part}_trim_iron
|
||||||
- when: minecraft:netherite
|
- when: minecraft:netherite
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_netherite_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_netherite_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_netherite
|
layer1: minecraft:trims/items/${part}_trim_netherite
|
||||||
- when: minecraft:redstone
|
- when: minecraft:redstone
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_redstone_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_redstone_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_redstone
|
layer1: minecraft:trims/items/${part}_trim_redstone
|
||||||
- when: minecraft:copper
|
- when: minecraft:copper
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_copper_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_copper_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_copper
|
layer1: minecraft:trims/items/${part}_trim_copper
|
||||||
- when: minecraft:gold
|
- when: minecraft:gold
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_gold_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_gold_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_gold
|
layer1: minecraft:trims/items/${part}_trim_gold
|
||||||
- when: minecraft:emerald
|
- when: minecraft:emerald
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_emerald_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_emerald_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_emerald
|
layer1: minecraft:trims/items/${part}_trim_emerald
|
||||||
- when: minecraft:diamond
|
- when: minecraft:diamond
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_diamond_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_diamond_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_diamond
|
layer1: minecraft:trims/items/${part}_trim_diamond
|
||||||
- when: minecraft:lapis
|
- when: minecraft:lapis
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_lapis_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_lapis_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_lapis
|
layer1: minecraft:trims/items/${part}_trim_lapis
|
||||||
- when: minecraft:amethyst
|
- when: minecraft:amethyst
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_amethyst_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_amethyst_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_amethyst
|
layer1: minecraft:trims/items/${part}_trim_amethyst
|
||||||
- when: minecraft:resin
|
- when: minecraft:resin
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/${material}_${part}_resin_trim
|
path: ${__NAMESPACE__}:item/${material}_${part}_resin_trim
|
||||||
generation:
|
generation:
|
||||||
parent: minecraft:item/generated
|
parent: minecraft:item/generated
|
||||||
textures:
|
textures:
|
||||||
layer0: minecraft:item/custom/${material}_${part}
|
layer0: ${texture}
|
||||||
layer1: minecraft:trims/items/${part}_trim_resin
|
layer1: minecraft:trims/items/${part}_trim_resin
|
||||||
|
|
||||||
# shield
|
# shield
|
||||||
|
|||||||
@@ -232,6 +232,13 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
return Collections.unmodifiableList(this.customItemTags.getOrDefault(tag, List.of()));
|
return Collections.unmodifiableList(this.customItemTags.getOrDefault(tag, List.of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Key> itemTags() {
|
||||||
|
Set<Key> tags = new HashSet<>(VANILLA_ITEM_TAGS.keySet());
|
||||||
|
tags.addAll(this.customItemTags.keySet());
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Suggestion> cachedCustomItemSuggestions() {
|
public Collection<Suggestion> cachedCustomItemSuggestions() {
|
||||||
return Collections.unmodifiableCollection(this.cachedCustomItemSuggestions);
|
return Collections.unmodifiableCollection(this.cachedCustomItemSuggestions);
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ public interface ItemManager<T> extends Manageable, ModelGenerator {
|
|||||||
|
|
||||||
int fuelTime(Key id);
|
int fuelTime(Key id);
|
||||||
|
|
||||||
|
Collection<Key> itemTags();
|
||||||
|
|
||||||
Collection<Suggestion> cachedCustomItemSuggestions();
|
Collection<Suggestion> cachedCustomItemSuggestions();
|
||||||
|
|
||||||
Collection<Suggestion> cachedAllItemSuggestions();
|
Collection<Suggestion> cachedAllItemSuggestions();
|
||||||
|
|||||||
@@ -143,9 +143,12 @@ public abstract class AbstractRecipeSerializer<T, R extends Recipe<T>> implement
|
|||||||
Set<UniqueKey> itemIds = new HashSet<>();
|
Set<UniqueKey> itemIds = new HashSet<>();
|
||||||
Set<UniqueKey> minecraftItemIds = new HashSet<>();
|
Set<UniqueKey> minecraftItemIds = new HashSet<>();
|
||||||
ItemManager<T> itemManager = CraftEngine.instance().itemManager();
|
ItemManager<T> itemManager = CraftEngine.instance().itemManager();
|
||||||
|
List<IngredientElement> elements = new ArrayList<>();
|
||||||
for (String item : items) {
|
for (String item : items) {
|
||||||
if (item.charAt(0) == '#') {
|
if (item.charAt(0) == '#') {
|
||||||
List<UniqueKey> uniqueKeys = itemManager.itemIdsByTag(Key.of(item.substring(1)));
|
Key tag = Key.of(item.substring(1));
|
||||||
|
elements.add(new IngredientElement.Tag(tag));
|
||||||
|
List<UniqueKey> uniqueKeys = itemManager.itemIdsByTag(tag);
|
||||||
itemIds.addAll(uniqueKeys);
|
itemIds.addAll(uniqueKeys);
|
||||||
for (UniqueKey uniqueKey : uniqueKeys) {
|
for (UniqueKey uniqueKey : uniqueKeys) {
|
||||||
List<UniqueKey> ingredientSubstitutes = itemManager.getIngredientSubstitutes(uniqueKey.key());
|
List<UniqueKey> ingredientSubstitutes = itemManager.getIngredientSubstitutes(uniqueKey.key());
|
||||||
@@ -155,6 +158,7 @@ public abstract class AbstractRecipeSerializer<T, R extends Recipe<T>> implement
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Key itemId = Key.of(item);
|
Key itemId = Key.of(item);
|
||||||
|
elements.add(new IngredientElement.Item(itemId));
|
||||||
if (itemManager.getBuildableItem(itemId).isEmpty()) {
|
if (itemManager.getBuildableItem(itemId).isEmpty()) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.recipe.invalid_ingredient", item);
|
throw new LocalizedResourceConfigException("warning.config.recipe.invalid_ingredient", item);
|
||||||
}
|
}
|
||||||
@@ -189,6 +193,6 @@ public abstract class AbstractRecipeSerializer<T, R extends Recipe<T>> implement
|
|||||||
}
|
}
|
||||||
minecraftItemIds.add(vanillaItem);
|
minecraftItemIds.add(vanillaItem);
|
||||||
}
|
}
|
||||||
return itemIds.isEmpty() ? null : Ingredient.of(itemIds, minecraftItemIds, hasCustomItem);
|
return itemIds.isEmpty() ? null : Ingredient.of(elements, itemIds, minecraftItemIds, hasCustomItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.*;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class Ingredient<T> implements Predicate<UniqueIdItem<T>>, StackedContents.IngredientInfo<UniqueKey> {
|
public class Ingredient<T> implements Predicate<UniqueIdItem<T>>, StackedContents.IngredientInfo<UniqueKey> {
|
||||||
|
private final List<IngredientElement> elements;
|
||||||
// 自定义物品与原版物品混合的列表
|
// 自定义物品与原版物品混合的列表
|
||||||
private final List<UniqueKey> items;
|
private final List<UniqueKey> items;
|
||||||
// 自定义物品原版材质与原版物品混合的列表
|
// 自定义物品原版材质与原版物品混合的列表
|
||||||
@@ -13,7 +14,8 @@ public class Ingredient<T> implements Predicate<UniqueIdItem<T>>, StackedContent
|
|||||||
// ingredient里是否含有自定义物品
|
// ingredient里是否含有自定义物品
|
||||||
private final boolean hasCustomItem;
|
private final boolean hasCustomItem;
|
||||||
|
|
||||||
private Ingredient(List<UniqueKey> items, List<UniqueKey> vanillaItems, boolean hasCustomItem) {
|
private Ingredient(List<IngredientElement> elements, List<UniqueKey> items, List<UniqueKey> vanillaItems, boolean hasCustomItem) {
|
||||||
|
this.elements = List.copyOf(elements);
|
||||||
this.items = List.copyOf(items);
|
this.items = List.copyOf(items);
|
||||||
this.vanillaItems = List.copyOf(vanillaItems);
|
this.vanillaItems = List.copyOf(vanillaItems);
|
||||||
this.hasCustomItem = hasCustomItem;
|
this.hasCustomItem = hasCustomItem;
|
||||||
@@ -24,12 +26,8 @@ public class Ingredient<T> implements Predicate<UniqueIdItem<T>>, StackedContent
|
|||||||
.orElseGet(stack::isEmpty);
|
.orElseGet(stack::isEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Ingredient<T> of(Set<UniqueKey> items, Set<UniqueKey> minecraftItems, boolean hasCustomItem) {
|
public static <T> Ingredient<T> of(List<IngredientElement> elements, Set<UniqueKey> items, Set<UniqueKey> minecraftItems, boolean hasCustomItem) {
|
||||||
return new Ingredient<>(new ArrayList<>(items), new ArrayList<>(minecraftItems), hasCustomItem);
|
return new Ingredient<>(elements, new ArrayList<>(items), new ArrayList<>(minecraftItems), hasCustomItem);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasCustomItem() {
|
|
||||||
return hasCustomItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -42,6 +40,14 @@ public class Ingredient<T> implements Predicate<UniqueIdItem<T>>, StackedContent
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<IngredientElement> elements() {
|
||||||
|
return this.elements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCustomItem() {
|
||||||
|
return this.hasCustomItem;
|
||||||
|
}
|
||||||
|
|
||||||
public List<UniqueKey> items() {
|
public List<UniqueKey> items() {
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.momirealms.craftengine.core.item.recipe;
|
||||||
|
|
||||||
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
|
|
||||||
|
public sealed interface IngredientElement permits IngredientElement.Item, IngredientElement.Tag {
|
||||||
|
|
||||||
|
record Item(Key id) implements IngredientElement {
|
||||||
|
}
|
||||||
|
|
||||||
|
record Tag(Key tag) implements IngredientElement {
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user