aboutsummaryrefslogtreecommitdiff
path: root/default-plugin/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-21 00:01:14 +0800
committershedaniel <daniel@shedaniel.me>2022-06-21 00:01:14 +0800
commit699259500bf8a54fe65f5503e59d6cfb696ba721 (patch)
treeedeffa242f9c0f791fa92141e9c9bef656573b04 /default-plugin/src/main/java
parented7b4ba6d052c6324259a37f0dc834650b6ff1e2 (diff)
downloadRoughlyEnoughItems-699259500bf8a54fe65f5503e59d6cfb696ba721.tar.gz
RoughlyEnoughItems-699259500bf8a54fe65f5503e59d6cfb696ba721.tar.bz2
RoughlyEnoughItems-699259500bf8a54fe65f5503e59d6cfb696ba721.zip
Add tag helper methods in EntryIngredients
Diffstat (limited to 'default-plugin/src/main/java')
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java40
1 files changed, 14 insertions, 26 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
index ec6c8edaa..5e514af3d 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
@@ -43,7 +43,7 @@ import me.shedaniel.rei.api.client.registry.screen.ExclusionZones;
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
-import me.shedaniel.rei.api.common.util.CollectionUtils;
+import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.ClientInternals;
@@ -75,12 +75,9 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screens.inventory.*;
import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener;
-import net.minecraft.core.Holder;
-import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
-import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
@@ -195,32 +192,23 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
registry.addWorkstations(PATHING, EntryStacks.of(item));
}
});
- for (Item item : getTag(new ResourceLocation("c", "axes"))) {
- if (axes.add(item)) {
- registry.addWorkstations(STRIPPING, EntryStacks.of(item));
- registry.addWorkstations(WAX_SCRAPING, EntryStacks.of(item));
- registry.addWorkstations(OXIDATION_SCRAPING, EntryStacks.of(item));
+ for (EntryStack<?> stack : getTag(new ResourceLocation("c", "axes"))) {
+ if (axes.add(stack.<ItemStack>castValue().getItem())) {
+ registry.addWorkstations(STRIPPING, stack);
+ registry.addWorkstations(WAX_SCRAPING, stack);
+ registry.addWorkstations(OXIDATION_SCRAPING, stack);
}
}
- for (Item item : getTag(new ResourceLocation("c", "hoes"))) {
- if (hoes.add(item)) registry.addWorkstations(TILLING, EntryStacks.of(item));
+ for (EntryStack<?> stack : getTag(new ResourceLocation("c", "hoes"))) {
+ if (hoes.add(stack.<ItemStack>castValue().getItem())) registry.addWorkstations(TILLING, stack);
}
- for (Item item : getTag(new ResourceLocation("c", "shovels"))) {
- if (shovels.add(item)) registry.addWorkstations(PATHING, EntryStacks.of(item));
+ for (EntryStack<?> stack : getTag(new ResourceLocation("c", "shovels"))) {
+ if (shovels.add(stack.<ItemStack>castValue().getItem())) registry.addWorkstations(PATHING, stack);
}
}
- private static <T> Iterable<T> resolveTag(TagKey<T> tagKey) {
- Registry<T> registry = ((Registry<Registry<T>>) Registry.REGISTRY).get((ResourceKey<Registry<T>>) tagKey.registry());
- HolderSet.Named<T> holders = registry.getTag(tagKey).orElse(null);
- if (holders == null) return Collections.emptyList();
- return () -> holders.stream()
- .map(Holder::value)
- .iterator();
- }
-
- private static Iterable<Item> getTag(ResourceLocation tagId) {
- return resolveTag(TagKey.create(Registry.ITEM_REGISTRY, tagId));
+ private static EntryIngredient getTag(ResourceLocation tagId) {
+ return EntryIngredients.ofItemTag(TagKey.create(Registry.ITEM_REGISTRY, tagId));
}
@Override
@@ -271,8 +259,8 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
DummyShovelItem.getPathBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultPathingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue().getBlock())));
});
- registry.add(new DefaultBeaconBaseDisplay(CollectionUtils.map(resolveTag(BlockTags.BEACON_BASE_BLOCKS), ItemStack::new)));
- registry.add(new DefaultBeaconPaymentDisplay(CollectionUtils.map(resolveTag(ItemTags.BEACON_PAYMENT_ITEMS), ItemStack::new)));
+ registry.add(new DefaultBeaconBaseDisplay(Collections.singletonList(EntryIngredients.ofItemTag(BlockTags.BEACON_BASE_BLOCKS)), Collections.emptyList()));
+ registry.add(new DefaultBeaconPaymentDisplay(Collections.singletonList(EntryIngredients.ofItemTag(ItemTags.BEACON_PAYMENT_ITEMS)), Collections.emptyList()));
HoneycombItem.WAXABLES.get().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultWaxingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue())));
});