diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-07-06 17:16:20 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-07-06 17:16:20 +0800 |
| commit | 84ce034ad0eeffd6e88ea7a1cae821779b620841 (patch) | |
| tree | 324e5b434199b44eadab99b5e655626693aab3a5 /default-plugin/src/main/java/me/shedaniel | |
| parent | 3df8ca8d31d6e49373f38075de6235653c006551 (diff) | |
| download | RoughlyEnoughItems-84ce034ad0eeffd6e88ea7a1cae821779b620841.tar.gz RoughlyEnoughItems-84ce034ad0eeffd6e88ea7a1cae821779b620841.tar.bz2 RoughlyEnoughItems-84ce034ad0eeffd6e88ea7a1cae821779b620841.zip | |
Fix #970
Diffstat (limited to 'default-plugin/src/main/java/me/shedaniel')
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 24296cfaa..94cab72f8 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 @@ -129,7 +129,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), new TextComponent("Failed to resolve tags!")), - Widgets.createLabel(new Point(innerBounds.getCenterX(), innerBounds.getCenterY() - 8), new TextComponent(dataResult.error().get().message())) + Widgets.createLabel(new Point(innerBounds.getCenterX(), innerBounds.getCenterY() + 1), new TextComponent(dataResult.error().get().message())) ), overflowBounds); } else { tagNode[0] = dataResult.result().get(); @@ -157,7 +157,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 0af08667f..4fcc002a0 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 @@ -179,13 +179,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<>(); @@ -201,11 +201,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)); } } |
