aboutsummaryrefslogtreecommitdiff
path: root/default-plugin/src/main/java/me/shedaniel/rei/plugin/client
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2024-11-10 20:07:35 +0800
committershedaniel <daniel@shedaniel.me>2024-11-10 20:08:06 +0800
commit7343b3cc169b52900c251eeab0e2baaeb82aaf45 (patch)
tree7379b1cda76d76bbe800870e10b726e2bdb8c4d5 /default-plugin/src/main/java/me/shedaniel/rei/plugin/client
parent2f2be7e3b8e5d99cf7a76ce51c13ad01be8ca309 (diff)
downloadRoughlyEnoughItems-7343b3cc169b52900c251eeab0e2baaeb82aaf45.tar.gz
RoughlyEnoughItems-7343b3cc169b52900c251eeab0e2baaeb82aaf45.tar.bz2
RoughlyEnoughItems-7343b3cc169b52900c251eeab0e2baaeb82aaf45.zip
Fix #1751
Diffstat (limited to 'default-plugin/src/main/java/me/shedaniel/rei/plugin/client')
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java9
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java40
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java38
3 files changed, 31 insertions, 56 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java
index 6f7a668d3..95b62a5fe 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java
@@ -23,12 +23,13 @@
package me.shedaniel.rei.plugin.client.categories.crafting.filler;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
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.plugin.common.displays.crafting.DefaultCustomShapelessDisplay;
+import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.DyeItem;
@@ -43,7 +44,11 @@ public class ArmorDyeRecipeFiller implements CraftingRecipeFiller<ArmorDyeRecipe
@Override
public Collection<Display> apply(RecipeHolder<ArmorDyeRecipe> recipe) {
List<Display> displays = new ArrayList<>();
- List<EntryStack<?>> toDye = EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().is(ItemTags.DYEABLE)).toList();
+ List<EntryStack<?>> toDye = BuiltInRegistries.ITEM.stream()
+ .filter(item -> item.builtInRegistryHolder().is(ItemTags.DYEABLE))
+ .map(EntryStacks::of)
+ .<EntryStack<?>>map(EntryStack::cast)
+ .toList();
DyeColor[] colors = DyeColor.values();
for (EntryStack<?> armor : toDye) {
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
index 2b8d3d0bb..d336cc2f3 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
@@ -24,14 +24,7 @@
package me.shedaniel.rei.plugin.client.categories.crafting.filler;
import me.shedaniel.rei.api.common.display.Display;
-import me.shedaniel.rei.api.common.entry.EntryIngredient;
-import me.shedaniel.rei.api.common.entry.EntryStack;
-import me.shedaniel.rei.api.common.util.EntryIngredients;
-import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay;
-import net.minecraft.ChatFormatting;
-import net.minecraft.client.resources.language.I18n;
-import net.minecraft.network.chat.Component;
-import net.minecraft.world.item.Items;
+import me.shedaniel.rei.plugin.common.displays.crafting.MapExtendingCraftingDisplay;
import net.minecraft.world.item.crafting.MapExtendingRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
@@ -46,19 +39,7 @@ public class MapExtendingRecipeFiller implements CraftingRecipeFiller<MapExtendi
List<Display> displays = new ArrayList<>();
for (int i = 0; i < 4; i++) {
- EntryIngredient[] inputs = new EntryIngredient[9];
- for (int j = 0; j < 9; j++) {
- if (j == 4) {
- inputs[j] = mapWith("X", i, 1);
- } else {
- inputs[j] = EntryIngredients.of(Items.PAPER);
- }
- }
-
- displays.add(new DefaultCustomDisplay(
- List.of(inputs),
- List.of(mapWith("X", i + 1, 1)),
- Optional.of(recipe.id().location())));
+ displays.add(new MapExtendingCraftingDisplay(i, Optional.of(recipe.id().location())));
}
return displays;
@@ -68,21 +49,4 @@ public class MapExtendingRecipeFiller implements CraftingRecipeFiller<MapExtendi
public Class<MapExtendingRecipe> getRecipeClass() {
return MapExtendingRecipe.class;
}
-
- public static EntryIngredient mapWith(String mapId, int scale, int count) {
- EntryIngredient stacks = EntryIngredients.of(Items.FILLED_MAP, count);
- String unknown = I18n.get("filled_map.unknown");
- for (EntryStack<?> stack : stacks) {
- stack.tooltipProcessor(($, tooltip) -> {
- tooltip.entries().removeIf(entry -> entry.isText() && entry.getAsText().getString().equals(unknown));
- return tooltip;
- });
- stack.tooltip(
- Component.translatable("filled_map.id", mapId).withStyle(ChatFormatting.GRAY),
- Component.translatable("filled_map.scale", (1 << scale)).withStyle(ChatFormatting.GRAY),
- Component.translatable("filled_map.level", scale, 4).withStyle(ChatFormatting.GRAY)
- );
- }
- return stacks;
- }
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
index 91b94b0e8..d8118ddaa 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
@@ -23,13 +23,16 @@
package me.shedaniel.rei.plugin.client.categories.crafting.filler;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
import me.shedaniel.rei.api.common.display.Display;
+import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay;
+import net.minecraft.core.Registry;
+import net.minecraft.core.RegistryAccess;
import net.minecraft.core.component.DataComponents;
+import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@@ -46,21 +49,24 @@ public class TippedArrowRecipeFiller implements CraftingRecipeFiller<TippedArrow
Set<ResourceLocation> registeredPotions = new HashSet<>();
List<Display> displays = new ArrayList<>();
- EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().getItem() == Items.LINGERING_POTION).forEach(entry -> {
- ItemStack itemStack = (ItemStack) entry.getValue();
- PotionContents potion = itemStack.get(DataComponents.POTION_CONTENTS);
- if (potion.potion().isPresent() && potion.potion().get().unwrapKey().isPresent() && registeredPotions.add(potion.potion().get().unwrapKey().get().location())) {
- List<EntryIngredient> input = new ArrayList<>();
- for (int i = 0; i < 4; i++)
- input.add(arrowStack);
- input.add(EntryIngredients.of(itemStack));
- for (int i = 0; i < 4; i++)
- input.add(arrowStack);
- ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8);
- outputStack.set(DataComponents.POTION_CONTENTS, potion);
- displays.add(new DefaultCustomDisplay(input, List.of(EntryIngredients.of(outputStack)), Optional.of(recipe.id().location())));
- }
- });
+ RegistryAccess registryAccess = BasicDisplay.registryAccess();
+ BasicDisplay.registryAccess().lookup(Registries.POTION).stream()
+ .flatMap(Registry::listElements)
+ .map(reference -> PotionContents.createItemStack(Items.LINGERING_POTION, reference))
+ .forEach(itemStack -> {
+ PotionContents potion = itemStack.get(DataComponents.POTION_CONTENTS);
+ if (potion.potion().isPresent() && potion.potion().get().unwrapKey().isPresent() && registeredPotions.add(potion.potion().get().unwrapKey().get().location())) {
+ List<EntryIngredient> input = new ArrayList<>();
+ for (int i = 0; i < 4; i++)
+ input.add(arrowStack);
+ input.add(EntryIngredients.of(itemStack));
+ for (int i = 0; i < 4; i++)
+ input.add(arrowStack);
+ ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8);
+ outputStack.set(DataComponents.POTION_CONTENTS, potion);
+ displays.add(new DefaultCustomDisplay(input, List.of(EntryIngredients.of(outputStack)), Optional.of(recipe.id().location())));
+ }
+ });
return displays;
}