Compare commits

..

1 commit

Author SHA1 Message Date
James Mitchell
fd4bd6a460
Merge 8dd052c9ca into ebd1db2d37 2024-10-22 14:29:45 +02:00
6 changed files with 10 additions and 40 deletions

View file

@ -3,17 +3,8 @@
All notable changes to this project will be documented in this file.
## Unreleased
- /
## [1.2.2] - 2024-10-23
- fixed crash on empty recipe JSONs
## [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 better logging for cases where items are assigned to multiple unification tags
- 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
@ -44,8 +35,6 @@ All notable changes to this project will be documented in this file.
Initial 1.21.1 port.
<!-- Versions -->
[1.2.2]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.21.1-1.2.2
[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.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

View file

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

View file

@ -2,7 +2,6 @@ package com.almostreliable.unified.unification.recipe;
import net.minecraft.resources.ResourceLocation;
import com.almostreliable.unified.AlmostUnifiedCommon;
import com.almostreliable.unified.api.unification.recipe.RecipeData;
import com.almostreliable.unified.utils.JsonCompare;
@ -18,7 +17,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public final class RecipeLink implements RecipeData {
public class RecipeLink implements RecipeData {
/**
* This cache is an optimization to avoid creating many ResourceLocations for just a few different types.
* Having fewer ResourceLocation instances can greatly speed up equality checking when these are used as map keys.
@ -31,30 +30,15 @@ public final class RecipeLink implements RecipeData {
@Nullable private DuplicateLink duplicateLink;
@Nullable private JsonObject unifiedRecipe;
private RecipeLink(ResourceLocation id, JsonObject originalRecipe, ResourceLocation type) {
public RecipeLink(ResourceLocation id, JsonObject originalRecipe) {
this.id = id;
this.originalRecipe = originalRecipe;
this.type = type;
}
@Nullable
public static RecipeLink of(ResourceLocation id, JsonObject originalRecipe) {
try {
ResourceLocation type = ResourceLocation.parse(originalRecipe.get("type").getAsString());
return new RecipeLink(id, originalRecipe, type);
} catch (Exception e) {
AlmostUnifiedCommon.LOGGER.warn("Could not detect recipe type for recipe '{}', skipping.", id);
return null;
}
}
public static RecipeLink ofOrThrow(ResourceLocation id, JsonObject originalRecipe) {
try {
String typeString = originalRecipe.get("type").getAsString();
ResourceLocation type = PARSED_TYPE_CACHE.computeIfAbsent(typeString, ResourceLocation::parse);
return new RecipeLink(id, originalRecipe, type);
this.type = PARSED_TYPE_CACHE.computeIfAbsent(typeString, ResourceLocation::parse);
} catch (Exception e) {
throw new IllegalArgumentException("could not detect recipe type for recipe " + id);
throw new IllegalArgumentException("could not detect recipe type");
}
}

View file

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

View file

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

View file

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