aboutsummaryrefslogtreecommitdiff
path: root/default-plugin/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-07-06 17:16:20 +0800
committershedaniel <daniel@shedaniel.me>2022-07-06 17:38:25 +0800
commit132818b186c11339f3ae7b73aab209ec85329293 (patch)
tree63d558017740366559ccae4dba7f94e7b9cbd978 /default-plugin/src/main/java
parent1c6216ba6df00cf2b535ace35b001d35ec010ed5 (diff)
downloadRoughlyEnoughItems-132818b186c11339f3ae7b73aab209ec85329293.tar.gz
RoughlyEnoughItems-132818b186c11339f3ae7b73aab209ec85329293.tar.bz2
RoughlyEnoughItems-132818b186c11339f3ae7b73aab209ec85329293.zip
Fix #970
Diffstat (limited to 'default-plugin/src/main/java')
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java17
2 files changed, 12 insertions, 9 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java
index e47a155a8..bd6c8b1df 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java
@@ -125,7 +125,7 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?,
if (dataResult.error().isPresent()) {
delegate[0] = Widgets.withBounds(Widgets.concat(
Widgets.createLabel(new Point(innerBounds.getCenterX(), innerBounds.getCenterY() - 8), Component.literal("Failed to resolve tags!")),
- Widgets.createLabel(new Point(innerBounds.getCenterX(), innerBounds.getCenterY() - 8), Component.literal(dataResult.error().get().message()))
+ Widgets.createLabel(new Point(innerBounds.getCenterX(), innerBounds.getCenterY() + 1), Component.literal(dataResult.error().get().message()))
), overflowBounds);
} else {
tagNode[0] = dataResult.result().get();
@@ -153,7 +153,7 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?,
}
return stack;
};
- delegate[0] = Widgets.overflowed(overflowBounds, Widgets.padded(16, new TagTreeWidget(tagNode[0], mapper)));
+ delegate[0] = Widgets.overflowed(overflowBounds, Widgets.padded(16, new TagTreeWidget(tagNode[0], mapper, overflowBounds)));
}
});
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java
index 5c3022b8a..30d28785b 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java
@@ -197,13 +197,13 @@ public class TagNodes {
public static <T> void create(TagKey<T> tagKey, Consumer<DataResult<TagNode<T>>> callback) {
Registry<T> registry = ((Registry<Registry<T>>) Registry.REGISTRY).get((ResourceKey<Registry<T>>) tagKey.registry());
requestTagData(tagKey.registry(), result -> {
- callback.accept(result.flatMap(dataMap -> dataMap != null ? resolveTag(tagKey, registry, dataMap) : DataResult.error("No tag data")));
+ callback.accept(result.flatMap(dataMap -> dataMap != null ? resolveTag(tagKey, registry, dataMap).orElse(DataResult.error("No tag data")) : DataResult.error("No tag data")));
});
}
- private static <T> DataResult<TagNode<T>> resolveTag(TagKey<T> tagKey, Registry<T> registry, Map<ResourceLocation, TagData> tagDataMap) {
+ private static <T> Optional<DataResult<TagNode<T>>> resolveTag(TagKey<T> tagKey, Registry<T> registry, Map<ResourceLocation, TagData> tagDataMap) {
TagData tagData = tagDataMap.get(tagKey.location());
- if (tagData == null) return DataResult.error("Tag Missing: " + tagKey.location());
+ if (tagData == null) return Optional.empty();
TagNode<T> self = TagNode.ofReference(tagKey);
List<Holder<T>> holders = new ArrayList<>();
@@ -219,11 +219,14 @@ public class TagNodes {
for (ResourceLocation childTagId : tagData.otherTags()) {
TagKey<T> childTagKey = TagKey.create(tagKey.registry(), childTagId);
if (registry.getTag(childTagKey).isPresent()) {
- DataResult<TagNode<T>> result = resolveTag(childTagKey, registry, tagDataMap);
- if (result.error().isPresent()) return DataResult.error(result.error().get().message());
- self.addChild(result.result().get());
+ Optional<DataResult<TagNode<T>>> resultOptional = resolveTag(childTagKey, registry, tagDataMap);
+ if (resultOptional.isPresent()) {
+ DataResult<TagNode<T>> result = resultOptional.get();
+ if (result.error().isPresent()) return Optional.of(DataResult.error(result.error().get().message()));
+ self.addChild(result.result().get());
+ }
}
}
- return DataResult.success(self);
+ return Optional.of(DataResult.success(self));
}
}