From 667c7993dcea8b09bdffcad9956b353f054ad6e2 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 17 Jun 2024 00:07:02 +0900 Subject: Update to 1.21 --- .../recipebook/DefaultRecipeBookHandler.java | 4 +-- .../rei/plugin/client/DefaultClientPlugin.java | 38 +++++++++++++--------- .../categories/DefaultInformationCategory.java | 17 +++++----- .../filler/BannerDuplicateRecipeFiller.java | 2 +- .../crafting/filler/CraftingRecipeFiller.java | 2 +- .../filler/ShieldDecorationRecipeFiller.java | 2 +- .../client/categories/tag/DefaultTagCategory.java | 6 ++-- .../categories/tag/ReferenceTagNodeWidget.java | 2 +- .../DefaultRecipeBookExclusionZones.java | 2 +- .../client/favorites/GameModeFavoriteEntry.java | 2 +- .../plugin/client/favorites/TimeFavoriteEntry.java | 4 +-- .../client/favorites/WeatherFavoriteEntry.java | 4 +-- .../rei/plugin/common/displays/tag/TagNodes.java | 4 +-- 13 files changed, 47 insertions(+), 42 deletions(-) (limited to 'default-plugin/src/main/java/me/shedaniel') diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/recipebook/DefaultRecipeBookHandler.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/recipebook/DefaultRecipeBookHandler.java index 5fc2affee..5f42f0303 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/recipebook/DefaultRecipeBookHandler.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/recipebook/DefaultRecipeBookHandler.java @@ -49,7 +49,7 @@ public class DefaultRecipeBookHandler implements TransferHandler { if (context.getDisplay() instanceof SimpleGridMenuDisplay && ClientHelper.getInstance().canUseMovePackets()) return ApplicabilityResult.createNotApplicable(); Display display = context.getDisplay(); - if (!(context.getMenu() instanceof RecipeBookMenu container)) + if (!(context.getMenu() instanceof RecipeBookMenu container)) return ApplicabilityResult.createNotApplicable(); if (container == null) return ApplicabilityResult.createNotApplicable(); @@ -58,7 +58,7 @@ public class DefaultRecipeBookHandler implements TransferHandler { @Override public Result handle(Context context) { - RecipeBookMenu container = (RecipeBookMenu) context.getMenu(); + RecipeBookMenu container = (RecipeBookMenu) context.getMenu(); Display display = context.getDisplay(); if (display instanceof DefaultCraftingDisplay craftingDisplay) { if (craftingDisplay.getOptionalRecipe().isPresent()) { 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 a651dbc4d..84629be4d 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 @@ -41,6 +41,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.client.registry.transfer.simple.SimpleTransferHandler; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; @@ -97,6 +98,7 @@ import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.PotionBrewing; import net.minecraft.world.item.alchemy.PotionContents; import net.minecraft.world.item.crafting.*; +import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentInstance; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; @@ -198,20 +200,20 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin @Override public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) { - registry.group(new ResourceLocation("roughlyenoughitems", "enchanted_book"), Component.translatable("item.minecraft.enchanted_book"), + registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "enchanted_book"), Component.translatable("item.minecraft.enchanted_book"), stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().is(Items.ENCHANTED_BOOK)); - registry.group(new ResourceLocation("roughlyenoughitems", "potion"), Component.translatable("item.minecraft.potion"), + registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "potion"), Component.translatable("item.minecraft.potion"), stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().is(Items.POTION)); - registry.group(new ResourceLocation("roughlyenoughitems", "splash_potion"), Component.translatable("item.minecraft.splash_potion"), + registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "splash_potion"), Component.translatable("item.minecraft.splash_potion"), stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().is(Items.SPLASH_POTION)); - registry.group(new ResourceLocation("roughlyenoughitems", "lingering_potion"), Component.translatable("item.minecraft.lingering_potion"), + registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "lingering_potion"), Component.translatable("item.minecraft.lingering_potion"), stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().is(Items.LINGERING_POTION)); - registry.group(new ResourceLocation("roughlyenoughitems", "spawn_egg"), Component.translatable("text.rei.spawn_egg"), + registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "spawn_egg"), Component.translatable("text.rei.spawn_egg"), stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().getItem() instanceof SpawnEggItem); - registry.group(new ResourceLocation("roughlyenoughitems", "tipped_arrow"), Component.translatable("item.minecraft.tipped_arrow"), + registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "tipped_arrow"), Component.translatable("item.minecraft.tipped_arrow"), stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().is(Items.TIPPED_ARROW)); - registry.group(new ResourceLocation("roughlyenoughitems", "music_disc"), Component.translatable("text.rei.music_disc"), - stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().getItem() instanceof RecordItem); + registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "music_disc"), Component.translatable("text.rei.music_disc"), + stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.castValue().has(DataComponents.JUKEBOX_PLAYABLE)); } @Override @@ -283,17 +285,17 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin registry.addWorkstations(PATHING, EntryStacks.of(item)); } }); - for (EntryStack stack : getTag(new ResourceLocation("c", "axes"))) { + for (EntryStack stack : getTag(ResourceLocation.fromNamespaceAndPath("c", "axes"))) { if (axes.add(stack.castValue().getItem())) { registry.addWorkstations(STRIPPING, stack); registry.addWorkstations(WAX_SCRAPING, stack); registry.addWorkstations(OXIDATION_SCRAPING, stack); } } - for (EntryStack stack : getTag(new ResourceLocation("c", "hoes"))) { + for (EntryStack stack : getTag(ResourceLocation.fromNamespaceAndPath("c", "hoes"))) { if (hoes.add(stack.castValue().getItem())) registry.addWorkstations(TILLING, stack); } - for (EntryStack stack : getTag(new ResourceLocation("c", "shovels"))) { + for (EntryStack stack : getTag(ResourceLocation.fromNamespaceAndPath("c", "shovels"))) { if (shovels.add(stack.castValue().getItem())) registry.addWorkstations(PATHING, stack); } } @@ -431,14 +433,18 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin Collections.singletonList(EntryIngredients.of(output.get().getLeft())), Optional.empty(), OptionalInt.of(output.get().getRight()))); } } - List> enchantmentBooks = BuiltInRegistries.ENCHANTMENT.stream() - .flatMap(enchantment -> { + List> enchantmentBooks = BasicDisplay.registryAccess().registry(Registries.ENCHANTMENT) + .stream() + .flatMap(Registry::holders) + .flatMap(holder -> { + if (!holder.isBound()) return Stream.empty(); + Enchantment enchantment = holder.value(); if (enchantment.getMaxLevel() - enchantment.getMinLevel() >= 10) { return IntStream.of(enchantment.getMinLevel(), enchantment.getMaxLevel()) - .mapToObj(lvl -> new EnchantmentInstance(enchantment, lvl)); + .mapToObj(lvl -> new EnchantmentInstance(holder, lvl)); } else { return IntStream.rangeClosed(enchantment.getMinLevel(), enchantment.getMaxLevel()) - .mapToObj(lvl -> new EnchantmentInstance(enchantment, lvl)); + .mapToObj(lvl -> new EnchantmentInstance(holder, lvl)); } }) .map(instance -> { @@ -450,7 +456,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin ItemStack itemStack = stack.castValue(); if (!itemStack.isEnchantable()) return; for (Pair pair : enchantmentBooks) { - if (!pair.getKey().enchantment.canEnchant(itemStack)) continue; + if (!pair.getKey().enchantment.value().canEnchant(itemStack)) continue; Optional> output = DefaultAnvilDisplay.calculateOutput(itemStack, pair.getValue()); if (output.isEmpty()) continue; registry.add(new DefaultAnvilDisplay(List.of(EntryIngredients.of(itemStack), EntryIngredients.of(pair.getValue())), diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java index d9c6c7c35..975491953 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java @@ -58,15 +58,14 @@ import java.util.Objects; @Environment(EnvType.CLIENT) public class DefaultInformationCategory implements DisplayCategory { - protected static void innerBlit(Matrix4f matrix4f, int xStart, int xEnd, int yStart, int yEnd, int z, float uStart, float uEnd, float vStart, float vEnd) { + protected static void innerBlit(GuiGraphics graphics, Matrix4f matrix4f, int xStart, int xEnd, int yStart, int yEnd, int z, float uStart, float uEnd, float vStart, float vEnd) { RenderSystem.setShader(GameRenderer::getPositionTexShader); - BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder(); - bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); - bufferBuilder.vertex(matrix4f, xStart, yEnd, z).uv(uStart, vEnd).endVertex(); - bufferBuilder.vertex(matrix4f, xEnd, yEnd, z).uv(uEnd, vEnd).endVertex(); - bufferBuilder.vertex(matrix4f, xEnd, yStart, z).uv(uEnd, vStart).endVertex(); - bufferBuilder.vertex(matrix4f, xStart, yStart, z).uv(uStart, vStart).endVertex(); - BufferUploader.drawWithShader(bufferBuilder.end()); + BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + bufferBuilder.addVertex(matrix4f, xStart, yEnd, z).setUv(uStart, vEnd); + bufferBuilder.addVertex(matrix4f, xEnd, yEnd, z).setUv(uEnd, vEnd); + bufferBuilder.addVertex(matrix4f, xEnd, yStart, z).setUv(uEnd, vStart); + bufferBuilder.addVertex(matrix4f, xStart, yStart, z).setUv(uStart, vStart); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); } @Override @@ -104,7 +103,7 @@ public class DefaultInformationCategory implements DisplayCategory>> displayMap = new HashMap<>(); for (Pair pair : ShieldDecorationRecipeFiller.randomizeBanners()) { - Optional bannerOptional = BuiltInRegistries.ITEM.getOptional(new ResourceLocation(pair.getFirst().getName() + "_banner")); + Optional bannerOptional = BuiltInRegistries.ITEM.getOptional(ResourceLocation.parse(pair.getFirst().getName() + "_banner")); if (bannerOptional.isEmpty()) continue; Pair> builderPair = displayMap.computeIfAbsent(pair.getFirst(), color -> Pair.of(EntryIngredient.builder(), EntryStacks.of(bannerOptional.get()))); builderPair.getFirst().add(EntryStacks.of(pair.getSecond())); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/CraftingRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/CraftingRecipeFiller.java index 8670ed6fc..bfe9383aa 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/CraftingRecipeFiller.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/CraftingRecipeFiller.java @@ -80,7 +80,7 @@ public interface CraftingRecipeFiller extends Function if (display.isShapeless()) { bounds.x -= 10; } - Widget widget = Widgets.createTexturedWidget(new ResourceLocation("roughlyenoughitems:textures/gui/info.png"), bounds.getX(), bounds.getY(), 0, 0, bounds.getWidth(), bounds.getHeight(), 1, 1, 1, 1); + Widget widget = Widgets.createTexturedWidget(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "textures/gui/info.png"), bounds.getX(), bounds.getY(), 0, 0, bounds.getWidth(), bounds.getHeight(), 1, 1, 1, 1); return Widgets.withTooltip(Widgets.withBounds(widget, bounds), texts); } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java index 2a74d4f66..f44dbc0af 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java @@ -52,7 +52,7 @@ public class ShieldDecorationRecipeFiller implements CraftingRecipeFiller bannerOptional = BuiltInRegistries.ITEM.getOptional(new ResourceLocation(color.getName() + "_banner")); + Optional bannerOptional = BuiltInRegistries.ITEM.getOptional(ResourceLocation.parse(color.getName() + "_banner")); if (bannerOptional.isEmpty()) continue; out.add(Pair.of(color, new ItemStack(bannerOptional.get()))); 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 7f0466cd8..420a96dbb 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 @@ -182,12 +182,12 @@ public class DefaultTagCategory implements DisplayCategory extends TagNodeWidget { public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), getBounds()))) { RenderSystem.setShader(GameRenderer::getPositionTexShader); - graphics.innerBlit(new ResourceLocation("textures/gui/sprites/advancements/task_frame_unobtained.png"), + graphics.innerBlit(ResourceLocation.withDefaultNamespace("textures/gui/sprites/advancements/task_frame_unobtained.png"), bounds.x - 1, bounds.x - 1 + 26, bounds.y - 1, bounds.y - 1 + 26, 0, 0, 1, 0, 1); this.slot.getBounds().setLocation(bounds.getCenterX() - this.slot.getBounds().getWidth() / 2, bounds.y + (bounds.height - this.slot.getBounds().getHeight()) / 2 + 1); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/exclusionzones/DefaultRecipeBookExclusionZones.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/exclusionzones/DefaultRecipeBookExclusionZones.java index 4afaa5674..49e7f7da3 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/exclusionzones/DefaultRecipeBookExclusionZones.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/exclusionzones/DefaultRecipeBookExclusionZones.java @@ -43,7 +43,7 @@ public class DefaultRecipeBookExclusionZones implements ExclusionZonesProvider provide(RecipeUpdateListener screen) { if (!(screen instanceof AbstractContainerScreen containerScreen) || !(((AbstractContainerScreen) screen).getMenu() instanceof RecipeBookMenu) || - !Minecraft.getInstance().player.getRecipeBook().isOpen(((RecipeBookMenu) ((AbstractContainerScreen) screen).getMenu()).getRecipeBookType())) + !Minecraft.getInstance().player.getRecipeBook().isOpen(((RecipeBookMenu) ((AbstractContainerScreen) screen).getMenu()).getRecipeBookType())) return Collections.emptyList(); RecipeBookComponent recipeBookWidget = screen.getRecipeBookComponent(); List l = Lists.newArrayList(new Rectangle(containerScreen.leftPos - 4 - 145, containerScreen.topPos, 4 + 145 + 30, containerScreen.imageHeight)); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java index d9ae50fe5..d58d4f501 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; public class GameModeFavoriteEntry extends FavoriteEntry { - public static final ResourceLocation ID = new ResourceLocation("roughlyenoughitems", "gamemode"); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "gamemode"); public static final String TRANSLATION_KEY = "favorite.section.gamemode"; public static final String KEY = "mode"; @Nullable diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java index 94139cf6e..b94222fc7 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java @@ -55,9 +55,9 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; public class TimeFavoriteEntry extends FavoriteEntry { - public static final ResourceLocation ID = new ResourceLocation("roughlyenoughitems", "time"); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "time"); public static final String TRANSLATION_KEY = "favorite.section.time"; - private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); + private static final ResourceLocation CHEST_GUI_TEXTURE = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "textures/gui/recipecontainer.png"); public static final String KEY = "mode"; @Nullable private final Time time; diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java index 94ea48476..6924e02ad 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java @@ -56,9 +56,9 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; public class WeatherFavoriteEntry extends FavoriteEntry { - public static final ResourceLocation ID = new ResourceLocation("roughlyenoughitems", "weather"); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "weather"); public static final String TRANSLATION_KEY = "favorite.section.weather"; - private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); + private static final ResourceLocation CHEST_GUI_TEXTURE = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "textures/gui/recipecontainer.png"); public static final String KEY = "weather"; @Nullable private final Weather weather; 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 488beb78e..b0aa10fef 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 @@ -55,8 +55,8 @@ import java.util.function.Consumer; @ApiStatus.Internal public class TagNodes { - public static final ResourceLocation REQUEST_TAGS_PACKET_C2S = new ResourceLocation("roughlyenoughitems", "request_tags_c2s"); - public static final ResourceLocation REQUEST_TAGS_PACKET_S2C = new ResourceLocation("roughlyenoughitems", "request_tags_s2c"); + public static final ResourceLocation REQUEST_TAGS_PACKET_C2S = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "request_tags_c2s"); + public static final ResourceLocation REQUEST_TAGS_PACKET_S2C = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "request_tags_s2c"); public static final Map>> TAG_DIR_MAP = new HashMap<>(); public static final ThreadLocal CURRENT_TAG_DIR = new ThreadLocal<>(); -- cgit