Compare commits

...

9 commits

Author SHA1 Message Date
rlnt
0d41ce5184 bump version
Some checks failed
Build / redirect (push) Has been cancelled
2024-10-22 12:58:37 +00:00
rlnt
d8b4afd57f
add skipping for recipes with invalid recipe type
fixes #100
2024-10-22 14:52:29 +02:00
rlnt
54529f60b1
add logging for recipes with invalid recipe type 2024-10-22 14:39:06 +02:00
rlnt
1f33027062
fix recipe type parsing not handling invalid cases 2024-10-22 14:33:03 +02:00
RuyaSavascisi
ebd1db2d37
add Turkish translation 2024-10-22 14:28:10 +02:00
rlnt
d3dcf67113
remove links from changelog 2024-10-22 14:22:01 +02:00
rlnt
5d76128d1b
fix runtime not being available on multiple unification tags 2024-10-22 14:21:29 +02:00
rlnt
9769c25a1c
fix new custom tags entries not being considered in unification 2024-10-22 13:59:20 +02:00
rlnt
84fcb8046d
prevent crashing when runtime isn't loaded
fixes #101
2024-10-22 13:59:20 +02:00
10 changed files with 69 additions and 29 deletions

View file

@ -2,12 +2,19 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog],
and this project adheres to [Semantic Versioning].
## Unreleased ## Unreleased
- / - /
## [1.2.1] - 2024-10-22
- added logging for cases where items are assigned to multiple unification tags
- added logging for cases where the recipe type can't be found
- added skipping logic for recipes with invalid recipe types
- added Turkish translation ([#102](https://github.com/AlmostReliable/almostunified/pull/102))
- fixed crash when runtime isn't loaded ([#101](https://github.com/AlmostReliable/almostunified/issues/101))
- fixed newly created custom tags not being considered for unification
- fixed runtime not being available when items are assigned to multiple unification tags
## [1.2.0] - 2024-10-06 ## [1.2.0] - 2024-10-06
- added support for custom ingredient types - added support for custom ingredient types
@ -32,11 +39,8 @@ and this project adheres to [Semantic Versioning].
Initial 1.21.1 port. Initial 1.21.1 port.
<!-- Links -->
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html
<!-- Versions --> <!-- Versions -->
[1.2.1]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.2.1
[1.2.0]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.2.0 [1.2.0]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.2.0
[1.1.0]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.1.0 [1.1.0]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.1.0
[1.0.0]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.0.0 [1.0.0]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.0.0

View file

@ -46,12 +46,12 @@ public final class AlmostUnifiedCommon {
} }
public static void onRecipeManagerError(ResourceLocation recipe) { public static void onRecipeManagerError(ResourceLocation recipe) {
assert RUNTIME != null; if (RUNTIME == null) return;
RUNTIME.getDebugHandler().collectRecipeError(recipe); RUNTIME.getDebugHandler().collectRecipeError(recipe);
} }
public static void onRecipeManagerEnd() { public static void onRecipeManagerEnd() {
assert RUNTIME != null; if (RUNTIME == null) return;
RUNTIME.getDebugHandler().finish(); RUNTIME.getDebugHandler().finish();
} }
} }

View file

@ -76,12 +76,7 @@ public final class AlmostUnifiedRuntimeImpl implements AlmostUnifiedRuntime {
var tagConfig = Config.load(TagConfig.NAME, TagConfig.SERIALIZER); var tagConfig = Config.load(TagConfig.NAME, TagConfig.SERIALIZER);
var unificationConfigs = UnificationConfig.safeLoadConfigs(); var unificationConfigs = UnificationConfig.safeLoadConfigs();
var unificationTags = bakeAndValidateTags( TagReloadHandler.applyCustomTags(tagConfig.getCustomTags(), itemTags);
unificationConfigs,
itemTags,
placeholderConfig,
debugConfig.shouldLogInvalidTags()
);
CustomIngredientUnifierRegistry ingredientUnifierRegistry = new CustomIngredientUnifierRegistryImpl(); CustomIngredientUnifierRegistry ingredientUnifierRegistry = new CustomIngredientUnifierRegistryImpl();
PluginManager.instance().registerCustomIngredientUnifiers(ingredientUnifierRegistry); PluginManager.instance().registerCustomIngredientUnifiers(ingredientUnifierRegistry);
@ -89,7 +84,13 @@ public final class AlmostUnifiedRuntimeImpl implements AlmostUnifiedRuntime {
PluginManager.instance().registerRecipeUnifiers(recipeUnifierRegistry); PluginManager.instance().registerRecipeUnifiers(recipeUnifierRegistry);
// TODO: add plugin support for registering config defaults // TODO: add plugin support for registering config defaults
TagReloadHandler.applyCustomTags(tagConfig.getCustomTags(), itemTags); var unificationTags = bakeAndValidateTags(
unificationConfigs,
itemTags,
placeholderConfig,
debugConfig.shouldLogInvalidTags()
);
TagSubstitutionsImpl tagSubstitutions = TagSubstitutionsImpl.create( TagSubstitutionsImpl tagSubstitutions = TagSubstitutionsImpl.create(
itemTags::has, itemTags::has,
unificationTags::contains, unificationTags::contains,

View file

@ -7,6 +7,7 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import com.almostreliable.unified.AlmostUnifiedCommon;
import com.almostreliable.unified.api.unification.ModPriorities; import com.almostreliable.unified.api.unification.ModPriorities;
import com.almostreliable.unified.api.unification.StoneVariants; import com.almostreliable.unified.api.unification.StoneVariants;
import com.almostreliable.unified.api.unification.TagSubstitutions; import com.almostreliable.unified.api.unification.TagSubstitutions;
@ -117,15 +118,22 @@ public final class UnificationLookupImpl implements UnificationLookup {
public static class Builder { public static class Builder {
private final Set<UnificationEntry<Item>> createdEntries = new HashSet<>(); private final Map<UnificationEntry<Item>, TagKey<Item>> entriesToTags = new HashMap<>();
private final Map<TagKey<Item>, Set<UnificationEntry<Item>>> tagsToEntries = new HashMap<>(); private final Map<TagKey<Item>, Set<UnificationEntry<Item>>> tagsToEntries = new HashMap<>();
private void put(TagKey<Item> tag, UnificationEntry<Item> entry) { private void put(TagKey<Item> tag, UnificationEntry<Item> entry) {
if (createdEntries.contains(entry)) { if (entriesToTags.containsKey(entry)) {
throw new IllegalStateException("entry " + entry + " already created"); var boundTag = entriesToTags.get(entry);
AlmostUnifiedCommon.LOGGER.error(
"Unification entry for item '{}' with tag '#{}' is already part of tag '#{}'.",
entry.id(),
tag.location(),
boundTag.location()
);
return;
} }
createdEntries.add(entry); entriesToTags.put(entry, tag);
tagsToEntries.computeIfAbsent(tag, $ -> new HashSet<>()).add(entry); tagsToEntries.computeIfAbsent(tag, $ -> new HashSet<>()).add(entry);
} }

View file

@ -28,7 +28,7 @@ public class RecipeJsonImpl implements RecipeJson {
try { try {
return ResourceLocation.parse(json.get("type").getAsString()); return ResourceLocation.parse(json.get("type").getAsString());
} catch (Exception e) { } catch (Exception e) {
throw new IllegalArgumentException("could not detect recipe type"); throw new IllegalArgumentException("could not detect recipe type for recipe " + id);
} }
} }

View file

@ -2,6 +2,7 @@ package com.almostreliable.unified.unification.recipe;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import com.almostreliable.unified.AlmostUnifiedCommon;
import com.almostreliable.unified.api.unification.recipe.RecipeData; import com.almostreliable.unified.api.unification.recipe.RecipeData;
import com.almostreliable.unified.utils.JsonCompare; import com.almostreliable.unified.utils.JsonCompare;
@ -15,21 +16,37 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class RecipeLink implements RecipeData { public final class RecipeLink implements RecipeData {
private final ResourceLocation id; private final ResourceLocation id;
private final ResourceLocation type; private final ResourceLocation type;
private final JsonObject originalRecipe; private final JsonObject originalRecipe;
@Nullable private DuplicateLink duplicateLink; @Nullable private DuplicateLink duplicateLink;
@Nullable private JsonObject unifiedRecipe; @Nullable private JsonObject unifiedRecipe;
public RecipeLink(ResourceLocation id, JsonObject originalRecipe) { private RecipeLink(ResourceLocation id, JsonObject originalRecipe, ResourceLocation type) {
this.id = id; this.id = id;
this.originalRecipe = originalRecipe; this.originalRecipe = originalRecipe;
this.type = type;
}
@Nullable
public static RecipeLink of(ResourceLocation id, JsonObject originalRecipe) {
ResourceLocation type = ResourceLocation.tryParse(originalRecipe.get("type").getAsString());
if (type == null) {
AlmostUnifiedCommon.LOGGER.warn("Could not detect recipe type for recipe '{}', skipping.", id);
return null;
}
return new RecipeLink(id, originalRecipe, type);
}
public static RecipeLink ofOrThrow(ResourceLocation id, JsonObject originalRecipe) {
try { try {
this.type = ResourceLocation.tryParse(originalRecipe.get("type").getAsString()); ResourceLocation type = ResourceLocation.parse(originalRecipe.get("type").getAsString());
return new RecipeLink(id, originalRecipe, type);
} catch (Exception e) { } catch (Exception e) {
throw new IllegalArgumentException("could not detect recipe type"); throw new IllegalArgumentException("could not detect recipe type for recipe " + id);
} }
} }

View file

@ -31,6 +31,7 @@ import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -111,7 +112,8 @@ public class RecipeTransformer {
return recipes return recipes
.entrySet() .entrySet()
.stream() .stream()
.map(entry -> new RecipeLink(entry.getKey(), entry.getValue().getAsJsonObject())) .map(entry -> RecipeLink.of(entry.getKey(), entry.getValue().getAsJsonObject()))
.filter(Objects::nonNull)
.sorted(Comparator.comparing(entry -> entry.getId().toString())) .sorted(Comparator.comparing(entry -> entry.getId().toString()))
.collect(Collectors.groupingByConcurrent(RecipeLink::getType)); .collect(Collectors.groupingByConcurrent(RecipeLink::getType));
} }

View file

@ -0,0 +1,8 @@
{
"almostunified.description": "Almost Unified tarafından değiştirildi!",
"almostunified.warning": "Tarif sorunlarını orijinal sahibine bildirmeyin.",
"almostunified.unified": "Birleştirilmiş",
"almostunified.duplicate": "Kopyaları Vardı",
"almostunified.yes": "Evet",
"almostunified.no": "Hayır"
}

View file

@ -83,11 +83,11 @@ public class TestUtils {
public static RecipeLink recipe(String jsonStr) { public static RecipeLink recipe(String jsonStr) {
var json = json(jsonStr); var json = json(jsonStr);
return new RecipeLink(ResourceLocation.parse("test"), json); return RecipeLink.ofOrThrow(ResourceLocation.parse("test"), json);
} }
public static RecipeLink recipe(JsonObject json) { public static RecipeLink recipe(JsonObject json) {
return new RecipeLink(ResourceLocation.parse("test"), json); return RecipeLink.ofOrThrow(ResourceLocation.parse("test"), json);
} }
public static JsonObject json(String json) { public static JsonObject json(String json) {

View file

@ -8,7 +8,7 @@ enableAccessWidener = false
minecraftVersion = 1.21.1 minecraftVersion = 1.21.1
# Mod # Mod
modVersion = 1.2.0 modVersion = 1.2.1
modPackage = com.almostreliable.unified modPackage = com.almostreliable.unified
modId = almostunified modId = almostunified
modName = AlmostUnified modName = AlmostUnified