9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-23 17:09:19 +00:00

学生需要减负

This commit is contained in:
XiaoMoMi
2025-04-29 03:44:43 +08:00
parent 1603e835b3
commit 26493b0ac8
54 changed files with 95 additions and 95 deletions

View File

@@ -55,7 +55,7 @@ public class BlockSettings {
if (factory != null) {
factory.createModifier(entry.getValue()).apply(settings);
} else {
throw new LocalizedResourceConfigException("warning.config.block.settings.unknown", new IllegalArgumentException("Unknown block settings key: " + entry.getKey()), entry.getKey());
throw new LocalizedResourceConfigException("warning.config.block.settings.unknown", entry.getKey());
}
}
return settings;

View File

@@ -27,12 +27,12 @@ public class BlockBehaviors {
if (map == null) return EmptyBlockBehavior.INSTANCE;
Object type = map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.block.behavior.missing_type", new NullPointerException("behavior type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.block.behavior.missing_type");
}
Key key = Key.withDefaultNamespace(type.toString(), "craftengine");
BlockBehaviorFactory factory = BuiltInRegistries.BLOCK_BEHAVIOR_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.block.behavior.invalid_type", new IllegalArgumentException("Unknown block behavior type: " + type), type.toString());
throw new LocalizedResourceConfigException("warning.config.block.behavior.invalid_type", type.toString());
}
return factory.create(block, map);
}

View File

@@ -37,12 +37,12 @@ public class Properties {
public static Property<?> fromMap(String name, Map<String, Object> map) {
Object type = map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.block.state.property.missing_type", new NullPointerException("'type' cannot be null for block state property"), name);
throw new LocalizedResourceConfigException("warning.config.block.state.property.missing_type", name);
}
Key key = Key.withDefaultNamespace(type.toString(), "craftengine");
PropertyFactory factory = BuiltInRegistries.PROPERTY_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.block.state.property.invalid_type", new IllegalArgumentException("Unknown property type: " + type), key.toString(), name);
throw new LocalizedResourceConfigException("warning.config.block.state.property.invalid_type", key.toString(), name);
}
return factory.create(name, map);
}

View File

@@ -39,7 +39,7 @@ public class FurnitureSettings {
if (factory != null) {
factory.createModifier(entry.getValue()).apply(settings);
} else {
throw new LocalizedResourceConfigException("warning.config.furniture.settings.unknown", new RuntimeException("Unknown furniture settings: " + entry.getKey()), entry.getKey());
throw new LocalizedResourceConfigException("warning.config.furniture.settings.unknown", entry.getKey());
}
}
return settings;

View File

@@ -27,7 +27,7 @@ public class HitBoxTypes {
Key type = Optional.ofNullable((String) arguments.get("type")).map(Key::of).orElse(HitBoxTypes.INTERACTION);
HitBoxFactory factory = BuiltInRegistries.HITBOX_FACTORY.getValue(type);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.furniture.hitbox.invalid_type", new IllegalArgumentException("Unknown hitbox type: " + type), type.toString());
throw new LocalizedResourceConfigException("warning.config.furniture.hitbox.invalid_type", type.toString());
}
return factory.create(arguments);
}

View File

@@ -59,7 +59,7 @@ public class ItemSettings {
if (factory != null) {
factory.createModifier(entry.getValue()).apply(settings);
} else {
throw new LocalizedResourceConfigException("warning.config.item.settings.unknown", new IllegalArgumentException("Unknown item settings key: " + entry.getKey()), entry.getKey());
throw new LocalizedResourceConfigException("warning.config.item.settings.unknown", entry.getKey());
}
}
return settings;

View File

@@ -24,12 +24,12 @@ public class ItemBehaviors {
public static ItemBehavior fromMap(Pack pack, Path path, Key id, Map<String, Object> map) {
Object type = map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.item.behavior.missing_type", new NullPointerException("behavior type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.item.behavior.missing_type");
}
Key key = Key.withDefaultNamespace(type.toString(), "craftengine");
ItemBehaviorFactory factory = BuiltInRegistries.ITEM_BEHAVIOR_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.item.behavior.invalid_type", new IllegalArgumentException("Unknown behavior type: " + type), type.toString());
throw new LocalizedResourceConfigException("warning.config.item.behavior.invalid_type", type.toString());
}
return factory.create(pack, path, id, map);
}

View File

@@ -26,7 +26,7 @@ public abstract class AbstractRecipeFactory<T> implements RecipeFactory<T> {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", item)));
}
}
return holders;
@@ -38,7 +38,7 @@ public abstract class AbstractRecipeFactory<T> implements RecipeFactory<T> {
ingredient = arguments.get("ingredients");
}
if (ingredient == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.missing_ingredient", new NullPointerException("'ingredient' should not be null"));
throw new LocalizedResourceConfigException("warning.config.recipe.missing_ingredient");
}
return ingredient;
}

View File

@@ -141,10 +141,10 @@ public class CustomShapedRecipe<T> extends CustomCraftingTableRecipe<T> {
public Recipe<A> create(Key id, Map<String, Object> arguments) {
List<String> pattern = MiscUtils.getAsStringList(arguments.get("pattern"));
if (pattern.isEmpty()) {
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.missing_pattern", new NullPointerException("'pattern' cannot be empty"));
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.missing_pattern");
}
if (!validatePattern(pattern)) {
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.invalid_pattern", new IllegalArgumentException("Invalid pattern: " + pattern), pattern.toString());
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.invalid_pattern", pattern.toString());
}
Object ingredientObj = getIngredientOrThrow(arguments);
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
@@ -152,7 +152,7 @@ public class CustomShapedRecipe<T> extends CustomCraftingTableRecipe<T> {
for (Map.Entry<String, Object> entry : MiscUtils.castToMap(ingredientObj, false).entrySet()) {
String key = entry.getKey();
if (key.length() != 1) {
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.invalid_symbol", new IllegalArgumentException("Invalid symbol: " + key), key);
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.invalid_symbol", key);
}
char ch = key.charAt(0);
List<String> items = MiscUtils.getAsStringList(entry.getValue());
@@ -162,7 +162,7 @@ public class CustomShapedRecipe<T> extends CustomCraftingTableRecipe<T> {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", item)));
}
}
ingredients.put(ch, Ingredient.of(holders));

View File

@@ -70,7 +70,7 @@ public class CustomShapelessRecipe<T> extends CustomCraftingTableRecipe<T> {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", item)));
}
}
ingredients.add(Ingredient.of(holders));
@@ -84,7 +84,7 @@ public class CustomShapelessRecipe<T> extends CustomCraftingTableRecipe<T> {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", item)));
}
}
ingredients.add(Ingredient.of(holders));
@@ -95,7 +95,7 @@ public class CustomShapelessRecipe<T> extends CustomCraftingTableRecipe<T> {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", item)));
}
ingredients.add(Ingredient.of(holders));
}
@@ -107,7 +107,7 @@ public class CustomShapelessRecipe<T> extends CustomCraftingTableRecipe<T> {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", item)));
}
ingredients.add(Ingredient.of(holders));
}

View File

@@ -151,7 +151,7 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", item)));
}
}
return holders.isEmpty() ? null : Ingredient.of(holders);
@@ -182,12 +182,12 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
public static ItemDataProcessor fromMap(Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.missing_type", new NullPointerException("Missing required parameter 'type' for post processor"));
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.missing_type");
}
Key key = Key.withDefaultNamespace(type, "craftengine");
ItemDataProcessor.Factory factory = BuiltInRegistries.SMITHING_RESULT_PROCESSOR_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.invalid_type", new IllegalArgumentException("Unknown processor type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.invalid_type", type);
}
return factory.create(map);
}
@@ -237,7 +237,7 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
public ItemDataProcessor create(Map<String, Object> arguments) {
Object componentsObj = arguments.get("components");
if (componentsObj == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components", new NullPointerException("Missing required parameter 'components' for post processor"));
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components");
}
List<String> components = MiscUtils.getAsStringList(componentsObj);
return new KeepComponents(components.stream().map(Key::of).toList());
@@ -274,7 +274,7 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
public ItemDataProcessor create(Map<String, Object> arguments) {
Object tagsObj = arguments.get("tags");
if (tagsObj == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags", new NullPointerException("Missing required parameter 'tags' for post processor"));
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags");
}
List<String> tags = MiscUtils.getAsStringList(tagsObj);
return new KeepTags(tags.stream().map(it -> it.split("\\.")).toList());

View File

@@ -16,16 +16,16 @@ public interface RecipeFactory<T> {
default CustomRecipeResult<T> parseResult(Map<String, Object> arguments) {
Map<String, Object> resultMap = MiscUtils.castToMap(arguments.get("result"), true);
if (resultMap == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.missing_result", new IllegalArgumentException("result cannot be empty for recipe"));
throw new LocalizedResourceConfigException("warning.config.recipe.missing_result");
}
String id = (String) resultMap.get("id");
if (id == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.result.missing_id", new IllegalArgumentException("id cannot be empty for result"));
throw new LocalizedResourceConfigException("warning.config.recipe.result.missing_id");
}
int count = ResourceConfigUtils.getAsInt(resultMap.getOrDefault("count", 1), "count");
return new CustomRecipeResult(
CraftEngine.instance().itemManager().getBuildableItem(Key.of(id)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Unknown recipe result item id: " + id), id)),
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", id)),
count
);
}

View File

@@ -42,12 +42,12 @@ public class RecipeTypes {
public static <T> Recipe<T> fromMap(Key id, Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.missing_type", new NullPointerException("'type' cannot be null for recipe"));
throw new LocalizedResourceConfigException("warning.config.recipe.missing_type");
}
Key key = Key.withDefaultNamespace(type, "minecraft");
RecipeFactory<T> factory = (RecipeFactory<T>) BuiltInRegistries.RECIPE_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.invalid_type", new IllegalArgumentException("Unknown recipe type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.recipe.invalid_type", type);
}
return factory.create(id, map);
}

View File

@@ -56,15 +56,15 @@ public class LootTable<T> {
NumberProvider bonus_rolls = NumberProviders.fromObject(pool.getOrDefault("bonus_rolls", 0));
List<LootCondition> conditions = Optional.ofNullable(pool.get("conditions"))
.map(it -> LootConditions.fromMapList(castToMapListOrThrow(it,
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_conditions_type", new RuntimeException("'conditions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName()))))
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_conditions_type", it.getClass().getSimpleName()))))
.orElse(Lists.newArrayList());
List<LootEntryContainer<T>> containers = Optional.ofNullable(pool.get("entries"))
.map(it -> (List<LootEntryContainer<T>>) new ArrayList<LootEntryContainer<T>>(LootEntryContainers.fromMapList(castToMapListOrThrow(it,
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_entries_type", new RuntimeException("'entries' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_entries_type", it.getClass().getSimpleName())))))
.orElse(Lists.newArrayList());
List<LootFunction<T>> functions = Optional.ofNullable(pool.get("functions"))
.map(it -> (List<LootFunction<T>>) new ArrayList<LootFunction<T>>(LootFunctions.fromMapList(castToMapListOrThrow(it,
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_functions_type", new RuntimeException("'functions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_functions_type", it.getClass().getSimpleName())))))
.orElse(Lists.newArrayList());
lootPools.add(new LootPool<>(containers, conditions, functions, rolls, bonus_rolls));
} else if (rawPool instanceof String string) {
@@ -76,7 +76,7 @@ public class LootTable<T> {
return new LootTable<>(lootPools,
Optional.ofNullable(map.get("functions"))
.map(it -> (List<LootFunction<T>>) new ArrayList<LootFunction<T>>(LootFunctions.fromMapList(castToMapListOrThrow(it,
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_functions_type", new RuntimeException("'functions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_functions_type", it.getClass().getSimpleName())))))
.orElse(Lists.newArrayList())
);
}

View File

@@ -90,12 +90,12 @@ public class LootConditions {
public static LootCondition fromMap(Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.missing_type", new NullPointerException("condition type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.missing_type");
}
Key key = Key.withDefaultNamespace(type, "craftengine");
LootConditionFactory factory = BuiltInRegistries.LOOT_CONDITION_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.invalid_type", new IllegalArgumentException("Unknown loot condition type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -46,7 +46,7 @@ public class ExpLootEntryContainer<T> extends AbstractLootEntryContainer<T> {
public LootEntryContainer<A> create(Map<String, Object> arguments) {
Object value = arguments.get("count");
if (value == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.exp.missing_count", new IllegalArgumentException("'count' is required for exp entry"));
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.exp.missing_count");
}
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))
.map(it -> LootConditions.fromMapList((List<Map<String, Object>>) it))

View File

@@ -42,12 +42,12 @@ public class LootEntryContainers {
public static <T> LootEntryContainer<T> fromMap(Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.missing_type", new NullPointerException("loot entry type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.missing_type");
}
Key key = Key.withDefaultNamespace(type, "craftengine");
LootEntryContainerFactory<T> factory = (LootEntryContainerFactory<T>) BuiltInRegistries.LOOT_ENTRY_CONTAINER_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.invalid_type", new IllegalArgumentException("Unknown loot entry type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -45,7 +45,7 @@ public class SingleItemLootEntryContainer<T> extends AbstractSingleLootEntryCont
public LootEntryContainer<A> create(Map<String, Object> arguments) {
Object itemObj = arguments.get("item");
if (itemObj == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.item.missing_item", new IllegalArgumentException("'item' is required for item entry"));
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.item.missing_item");
}
Key item = Key.from(itemObj.toString());
int weight = (int) arguments.getOrDefault("weight", 1);

View File

@@ -51,11 +51,11 @@ public class ApplyBonusCountFunction<T> extends AbstractLootConditionalFunction<
public LootFunction<T> create(Map<String, Object> arguments) {
String enchantment = (String) arguments.get("enchantment");
if (enchantment == null || enchantment.isEmpty()) {
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.missing_enchantment", new IllegalArgumentException("'enchantment' is required for apply_bonus function"));
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.missing_enchantment");
}
Map<String, Object> formulaMap = MiscUtils.castToMap(arguments.get("formula"), true);
if (formulaMap == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.missing_formula", new IllegalArgumentException("formula is required"));
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.missing_formula");
}
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))
.map(it -> LootConditions.fromMapList((List<Map<String, Object>>) it))

View File

@@ -42,7 +42,7 @@ public class DropExpFunction<T> extends AbstractLootConditionalFunction<T> {
public LootFunction<T> create(Map<String, Object> arguments) {
Object value = arguments.get("count");
if (value == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.function.drop_exp.missing_count", new IllegalArgumentException("'count' is required for drop_exp function"));
throw new LocalizedResourceConfigException("warning.config.loot_table.function.drop_exp.missing_count");
}
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))
.map(it -> LootConditions.fromMapList((List<Map<String, Object>>) it))

View File

@@ -70,12 +70,12 @@ public class LootFunctions {
public static <T> LootFunction<T> fromMap(Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.function.missing_type", new NullPointerException("function type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.loot_table.function.missing_type");
}
Key key = Key.withDefaultNamespace(type, "craftengine");
LootFunctionFactory<T> factory = (LootFunctionFactory<T>) BuiltInRegistries.LOOT_FUNCTION_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.function.invalid_type", new IllegalArgumentException("Unknown function type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.loot_table.function.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -44,7 +44,7 @@ public class SetCountFunction<T> extends AbstractLootConditionalFunction<T> {
public LootFunction<A> create(Map<String, Object> arguments) {
Object value = arguments.get("count");
if (value == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.function.set_count.missing_count", new IllegalArgumentException("'count' is required for set_count function"));
throw new LocalizedResourceConfigException("warning.config.loot_table.function.set_count.missing_count");
}
boolean add = (boolean) arguments.getOrDefault("add", false);
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))

View File

@@ -39,12 +39,12 @@ public class NumberProviders {
public static NumberProvider fromMap(Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.number.missing_type", new NullPointerException("number type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.loot_table.number.missing_type");
}
Key key = Key.withDefaultNamespace(type, "craftengine");
NumberProviderFactory factory = BuiltInRegistries.NUMBER_PROVIDER_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.loot_table.number.invalid_type", new IllegalArgumentException("Unknown number type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.loot_table.number.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -44,7 +44,7 @@ public class AllOfPathMatcher implements PathMatcher {
Map<String, Object> terms = MiscUtils.castToMap(termsObj, false);
return new AllOfPathMatcher(PathMatchers.fromMapList(List.of(terms)));
} else {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.all_of.missing_terms", new NullPointerException("terms should not be null for all_of"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.all_of.missing_terms");
}
}
}

View File

@@ -44,7 +44,7 @@ public class AnyOfPathMatcher implements PathMatcher {
Map<String, Object> terms = MiscUtils.castToMap(termsObj, false);
return new AnyOfPathMatcher(PathMatchers.fromMapList(List.of(terms)));
} else {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.any_of.missing_terms", new NullPointerException("terms should not be null for any_of"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.any_of.missing_terms");
}
}
}

View File

@@ -31,7 +31,7 @@ public class ExactPathMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) {
Object path = arguments.get("path");
if (path == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.exact.missing_path", new IllegalArgumentException("The 'path' argument must not be null"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.exact.missing_path");
}
return new ExactPathMatcher(path.toString());
}

View File

@@ -31,7 +31,7 @@ public class FilenameMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) {
Object name = arguments.get("name");
if (name == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.filename.missing_name", new IllegalArgumentException("The 'name' argument must not be null"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.filename.missing_name");
}
return new FilenameMatcher(name.toString());
}

View File

@@ -31,7 +31,7 @@ public class InvertedPathMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) {
Object inverted = arguments.get("term");
if (inverted == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.inverted.missing_term", new NullPointerException("term should not be null for inverted"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.inverted.missing_term");
}
Map<String, Object> term = MiscUtils.castToMap(inverted, false);
return new InvertedPathMatcher(PathMatchers.fromMap(term));

View File

@@ -33,7 +33,7 @@ public class ParentPathPrefixMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) {
Object prefix = arguments.get("prefix");
if (prefix == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_prefix.missing_prefix", new IllegalArgumentException("The prefix argument must not be null"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_prefix.missing_prefix");
}
return new ParentPathPrefixMatcher(prefix.toString());
}

View File

@@ -31,7 +31,7 @@ public class PathContainsMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) {
Object path = arguments.get("path");
if (path == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.contains.missing_path", new NullPointerException("path should not be null"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.contains.missing_path");
}
return new PathContainsMatcher(path.toString());
}

View File

@@ -51,12 +51,12 @@ public class PathMatchers {
public static PathMatcher fromMap(Map<String, Object> map) {
String type = (String) map.getOrDefault("type", "empty");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.missing_type", new NullPointerException("path matcher type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.missing_type");
}
Key key = Key.withDefaultNamespace(type, "craftengine");
PathMatcherFactory factory = BuiltInRegistries.PATH_MATCHER_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.invalid_type", new IllegalArgumentException("Unknown matcher type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -31,7 +31,7 @@ public class PathPatternMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) {
Object pattern = arguments.get("pattern");
if (pattern == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.pattern.missing_pattern", new IllegalArgumentException("The pattern argument must not be null"));
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.pattern.missing_pattern");
}
return new PathPatternMatcher(pattern.toString());
}

View File

@@ -71,11 +71,11 @@ public class BaseItemModel implements ItemModel {
public ItemModel create(Map<String, Object> arguments) {
Object path = arguments.get("path");
if (path == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.base.missing_path", new NullPointerException("'path' is required for 'minecraft:model'"));
throw new LocalizedResourceConfigException("warning.config.item.model.base.missing_path");
}
String modelPath = path.toString();
if (!ResourceLocation.isValid(modelPath)) {
throw new LocalizedResourceConfigException("warning.config.item.model.base.invalid_path", new IllegalArgumentException("Invalid resource location: " + modelPath), modelPath);
throw new LocalizedResourceConfigException("warning.config.item.model.base.invalid_path", modelPath);
}
Map<String, Object> generation = MiscUtils.castToMap(arguments.get("generation"), true);
ModelGeneration modelGeneration = null;

View File

@@ -58,7 +58,7 @@ public class CompositeItemModel implements ItemModel {
if (m instanceof List<?> list) {
List<Map<String, Object>> models = (List<Map<String, Object>>) list;
if (models.isEmpty()) {
throw new LocalizedResourceConfigException("warning.config.item.model.composite.missing_models", new IllegalArgumentException("'models' list should not be empty for 'minecraft:composite'"));
throw new LocalizedResourceConfigException("warning.config.item.model.composite.missing_models");
}
List<ItemModel> modelList = new ArrayList<>();
for (Map<String, Object> model : models) {
@@ -68,7 +68,7 @@ public class CompositeItemModel implements ItemModel {
} else if (m instanceof Map<?, ?> map) {
return new CompositeItemModel(List.of(ItemModels.fromMap(MiscUtils.castToMap(map, false))));
} else {
throw new LocalizedResourceConfigException("warning.config.item.model.composite.missing_models", new NullPointerException("'models' argument is required for 'minecraft:composite'"));
throw new LocalizedResourceConfigException("warning.config.item.model.composite.missing_models");
}
}
}

View File

@@ -68,13 +68,13 @@ public class ConditionItemModel implements ItemModel {
if (arguments.get("on-true") instanceof Map<?,?> map1) {
onTrue = ItemModels.fromMap(MiscUtils.castToMap(map1, false));
} else {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_on_true", new NullPointerException("'on-true' is required for condition"));
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_on_true");
}
ItemModel onFalse;
if (arguments.get("on-false") instanceof Map<?,?> map2) {
onFalse = ItemModels.fromMap(MiscUtils.castToMap(map2, false));
} else {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_on_false", new NullPointerException("'on-false' is required for condition"));
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_on_false");
}
return new ConditionItemModel(property, onTrue, onFalse);
}

View File

@@ -40,7 +40,7 @@ public class ItemModels {
Key key = Key.withDefaultNamespace(type, "minecraft");
ItemModelFactory factory = BuiltInRegistries.ITEM_MODEL_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.invalid_type", new IllegalArgumentException("Unknown model type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.item.model.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -109,16 +109,16 @@ public class RangeDispatchItemModel implements ItemModel {
float threshold = ResourceConfigUtils.getAsFloat(entry.getOrDefault("threshold", 1), "threshold");
Object model = entry.getOrDefault("model", fallback);
if (model == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.entry.missing_model", new NullPointerException("'model' is required for range_dispatch entry"));
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.entry.missing_model");
}
entryMap.put(threshold, ItemModels.fromMap(MiscUtils.castToMap(model, false)));
}
return new RangeDispatchItemModel(property, scale, fallback == null ? null : ItemModels.fromMap(fallback), entryMap);
} else {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_entries", new IllegalArgumentException("No entries found for range_dispatch"));
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_entries");
}
} else {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_entries", new NullPointerException("'entries' is required for the range_dispatch model"));
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_entries");
}
}
}

View File

@@ -106,7 +106,7 @@ public class SelectItemModel implements ItemModel {
for (Map<String, Object> c : cases) {
Object when = c.get("when");
if (when == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.missing_when", new NullPointerException("'when' should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.missing_when");
}
Either<String, List<String>> either;
if (when instanceof List<?> whenList) {
@@ -120,16 +120,16 @@ public class SelectItemModel implements ItemModel {
}
Object model = c.get("model");
if (model == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.missing_model", new NullPointerException("'model' should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.missing_model");
}
whenMap.put(either, ItemModels.fromMap(MiscUtils.castToMap(model, false)));
}
return new SelectItemModel(property, whenMap, fallback == null ? null : ItemModels.fromMap(fallback));
} else {
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_cases", new NullPointerException("'cases' is required for the select model"));
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_cases");
}
} else {
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_cases", new NullPointerException("'cases' is required for the select model"));
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_cases");
}
}
}

View File

@@ -48,12 +48,12 @@ public class ConditionProperties {
public static ConditionProperty fromMap(Map<String, Object> map) {
String type = (String) map.get("property");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_property", new NullPointerException("property type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_property");
}
Key key = Key.withDefaultNamespace(type, "minecraft");
ConditionPropertyFactory factory = BuiltInRegistries.CONDITION_PROPERTY_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.invalid_property", new IllegalArgumentException("Unknown property type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.item.model.condition.invalid_property", type);
}
return factory.create(map);
}

View File

@@ -38,7 +38,7 @@ public class HasComponentConditionProperty implements ConditionProperty {
boolean ignoreDefault = (boolean) arguments.getOrDefault("ignore-default", false);
Object componentObj = arguments.get("component");
if (componentObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.has_component.missing_component", new NullPointerException("component should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.condition.has_component.missing_component");
}
String component = componentObj.toString();
return new HasComponentConditionProperty(component, ignoreDefault);

View File

@@ -32,7 +32,7 @@ public class KeyBindDownConditionProperty implements ConditionProperty {
public ConditionProperty create(Map<String, Object> arguments) {
Object keybindObj = arguments.get("keybind");
if (keybindObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.keybind.missing", new NullPointerException("keybind should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.condition.keybind.missing");
}
String keybind = keybindObj.toString();
return new KeyBindDownConditionProperty(keybind);

View File

@@ -25,7 +25,7 @@ public class ModelGeneration {
this.path = path;
Object parent = map.get("parent");
if (parent == null) {
throw new LocalizedResourceConfigException("warning.config.model.generation.missing_parent", new NullPointerException("'parent' argument is required for generation"));
throw new LocalizedResourceConfigException("warning.config.model.generation.missing_parent");
}
this.parentModelPath = parent.toString();
Map<String, Object> texturesMap = MiscUtils.castToMap(map.get("textures"), true);

View File

@@ -32,7 +32,7 @@ public class CompassRangeDispatchProperty implements RangeDispatchProperty {
public RangeDispatchProperty create(Map<String, Object> arguments) {
Object targetObj = arguments.get("target");
if (targetObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.compass.missing_target", new NullPointerException("target should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.compass.missing_target");
}
String target = targetObj.toString();
return new CompassRangeDispatchProperty(target);

View File

@@ -44,12 +44,12 @@ public class RangeDispatchProperties {
public static RangeDispatchProperty fromMap(Map<String, Object> map) {
String type = (String) map.get("property");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_property", new NullPointerException("property type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_property");
}
Key key = Key.withDefaultNamespace(type, "minecraft");
RangeDispatchPropertyFactory factory = BuiltInRegistries.RANGE_DISPATCH_PROPERTY_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.invalid_property", new IllegalArgumentException("Unknown property type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.invalid_property", type);
}
return factory.create(map);
}

View File

@@ -37,7 +37,7 @@ public class TimeRangeDispatchProperty implements RangeDispatchProperty {
public RangeDispatchProperty create(Map<String, Object> arguments) {
Object sourceObj = arguments.get("source");
if (sourceObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.time.missing_source", new NullPointerException("source should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.time.missing_source");
}
String source = sourceObj.toString();
boolean wobble = (boolean) arguments.getOrDefault("wobble", true);

View File

@@ -32,7 +32,7 @@ public class BlockStateSelectProperty implements SelectProperty {
public SelectProperty create(Map<String, Object> arguments) {
Object property = arguments.get("block-state-property");
if (property == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.select.block_state.missing_property", new NullPointerException("block-state-property should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.select.block_state.missing_property");
}
String blockStateProperty = property.toString();
return new BlockStateSelectProperty(blockStateProperty);

View File

@@ -42,12 +42,12 @@ public class SelectProperties {
public static SelectProperty fromMap(Map<String, Object> map) {
String type = (String) map.get("property");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_property", new NullPointerException("property type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_property");
}
Key key = Key.withDefaultNamespace(type, "minecraft");
SelectPropertyFactory factory = BuiltInRegistries.SELECT_PROPERTY_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.select.invalid_property", new IllegalArgumentException("Unknown property type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.item.model.select.invalid_property", type);
}
return factory.create(map);
}

View File

@@ -45,12 +45,12 @@ public class SpecialModels {
public static SpecialModel fromMap(Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.missing_type", new NullPointerException("special model type cannot be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.special.missing_type");
}
Key key = Key.withDefaultNamespace(type, "minecraft");
SpecialModelFactory factory = BuiltInRegistries.SPECIAL_MODEL_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.invalid_type", new IllegalArgumentException("Unknown special model type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.item.model.special.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -35,7 +35,7 @@ public class ConstantTint implements Tint {
public Tint create(Map<String, Object> arguments) {
Object value = arguments.get("value");
if (value == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.tint.constant.missing_value", new NullPointerException("value should not be null"));
throw new LocalizedResourceConfigException("warning.config.item.model.tint.constant.missing_value");
}
return new ConstantTint(parseTintValue(value));
}

View File

@@ -39,10 +39,10 @@ public class GrassTint implements Tint {
float temperature = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("temperature", 0), "temperature");
float downfall = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("downfall", 0), "downfall");
if (temperature > 1 || temperature < 0) {
throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_temp", new IllegalArgumentException("Invalid temperature: " + temperature + ". Valid range 0~1"), String.valueOf(temperature));
throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_temp", String.valueOf(temperature));
}
if (downfall > 1 || downfall < 0) {
throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_downfall", new IllegalArgumentException("Invalid downfall: " + downfall + ". Valid range 0~1"), String.valueOf(downfall));
throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_downfall", String.valueOf(downfall));
}
return new GrassTint(temperature, downfall);
}

View File

@@ -32,6 +32,6 @@ public interface TintFactory {
return Either.ofFallback(intList);
}
}
throw new LocalizedResourceConfigException("warning.config.item.model.tint.invalid_value", new IllegalArgumentException("Invalid tint value: " + value), value.toString());
throw new LocalizedResourceConfigException("warning.config.item.model.tint.invalid_value", value.toString());
}
}

View File

@@ -40,12 +40,12 @@ public class Tints {
public static Tint fromMap(Map<String, Object> map) {
String type = (String) map.get("type");
if (type == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.tint.missing_type", new NullPointerException("'type' cannot be null for tint"));
throw new LocalizedResourceConfigException("warning.config.item.model.tint.missing_type");
}
Key key = Key.withDefaultNamespace(type, "minecraft");
TintFactory factory = BuiltInRegistries.TINT_FACTORY.getValue(key);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.tint.invalid_type", new IllegalArgumentException("Unknown tint type: " + type), type);
throw new LocalizedResourceConfigException("warning.config.item.model.tint.invalid_type", type);
}
return factory.create(map);
}

View File

@@ -53,7 +53,7 @@ public interface Sound extends Supplier<JsonElement> {
public static SoundFile fromMap(Map<String, Object> map) {
Object name = map.get("name");
if (name == null) throw new LocalizedResourceConfigException("warning.config.sound.missing_name", new NullPointerException("Missing required property 'name'"));
if (name == null) throw new LocalizedResourceConfigException("warning.config.sound.missing_name");
Builder builder = file(name.toString());
for (Map.Entry<String, Object> entry : map.entrySet()) {
Optional.ofNullable(Builder.MODIFIERS.get(entry.getKey())).ifPresent(modifier -> modifier.apply(builder, entry.getValue()));

View File

@@ -59,7 +59,7 @@ public class MiscUtils {
} else if (split.length == 1) {
return new Vector3f(Float.parseFloat(split[0]));
} else {
throw new LocalizedResourceConfigException("warning.config.type.vector3f", new RuntimeException("Cannot convert " + o + " to Vector3f"), stringFormat, option);
throw new LocalizedResourceConfigException("warning.config.type.vector3f", stringFormat, option);
}
}
@@ -72,7 +72,7 @@ public class MiscUtils {
} else if (split.length == 1) {
return QuaternionUtils.toQuaternionf(0, Math.toRadians(Float.parseFloat(split[0])), 0);
} else {
throw new LocalizedResourceConfigException("warning.config.type.quaternionf", new RuntimeException("Cannot convert " + o + " to Quaternionf"), stringFormat, option);
throw new LocalizedResourceConfigException("warning.config.type.quaternionf", stringFormat, option);
}
}
}