~williewillus/violet-moon

2 2

[PATCH patchouli] Port to 1.19.4

Details
Message ID
<20230521201817.22594-1-theArtemisSystem@gmail.com>
DKIM signature
missing
Download raw message
---
There is something wrong with the next/prev buttons, sometimes they seem to
"get stuck" and their tooltip always renders. I didn't have time to look into
it. In general not thoroughly tested either
I'm not sure if the recipe mapping tooltip renders correctly either, the test
book didn't seem to have any set up or it just wasn't working.
So, this isn't a very rigid port, but it's enough for other mods to depend
on i guess, if they need to start updating.
 Fabric/build.gradle                           |  4 +--
 Forge/build.gradle                            |  2 +-
 .../vazkii/patchouli/client/RenderHelper.java | 33 -------------------
 .../client/base/ClientAdvancements.java       |  3 +-
 .../patchouli/client/book/BookIcon.java       |  4 +--
 .../client/book/ClientBookRegistry.java       |  4 +--
 .../client/book/gui/GuiBookEntry.java         |  7 ++--
 .../client/book/gui/GuiBookEntryList.java     |  4 +--
 .../client/book/gui/button/GuiButtonBook.java |  2 +-
 .../gui/button/GuiButtonBookBookmark.java     |  4 +--
 .../book/gui/button/GuiButtonBookEye.java     |  4 +--
 .../gui/button/GuiButtonBookMarkRead.java     |  2 +-
 .../book/gui/button/GuiButtonCategory.java    |  2 +-
 .../book/gui/button/GuiButtonEntry.java       |  2 +-
 .../client/book/page/PageCrafting.java        | 13 ++++++--
 .../client/book/page/PageSmithing.java        | 21 ++++++++----
 .../page/abstr/PageDoubleRecipeRegistry.java  |  6 ++--
 .../abstr/PageSimpleProcessingRecipe.java     | 13 ++++++--
 .../template/test/RecipeTestProcessor.java    | 10 ++++--
 .../client/book/text/TextLayouter.java        | 11 +------
 .../client/gui/GuiButtonInventoryBook.java    |  5 ++-
 .../client/handler/BookRightClickHandler.java |  3 +-
 .../MultiblockVisualizationHandler.java       |  5 +--
 .../client/handler/TooltipHandler.java        | 11 +++----
 .../common/handler/LecternEventHandler.java   |  2 +-
 .../common/recipe/ShapedBookRecipe.java       |  7 +++-
 .../mixin/AccessorSmithingRecipe.java         |  5 +--
 gradle.properties                             |  2 +-
 28 files changed, 86 insertions(+), 105 deletions(-)
 delete mode 100644 Xplat/src/main/java/vazkii/patchouli/client/RenderHelper.java

diff --git a/Fabric/build.gradle b/Fabric/build.gradle
index 5e375a77..998d2b36 100644
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -61,9 +61,9 @@ dependencies {
 
 	minecraft "com.mojang:minecraft:${minecraft_version}"
 	mappings loom.officialMojangMappings()
-	modImplementation "net.fabricmc:fabric-loader:0.14.11"
+	modImplementation "net.fabricmc:fabric-loader:0.14.19"
 
-	modImplementation "net.fabricmc.fabric-api:fabric-api:0.68.1+1.19.3"
+	modImplementation "net.fabricmc.fabric-api:fabric-api:0.81.1+1.19.4"
     compileOnly project(":Xplat")
 
 	modCompileOnly "mezz.jei:jei-1.19.2-common-api:11.2.0.247"
diff --git a/Forge/build.gradle b/Forge/build.gradle
index 9e27adbc..791813f2 100644
--- a/Forge/build.gradle
+++ b/Forge/build.gradle
@@ -74,7 +74,7 @@ minecraft {
 }
 
 dependencies {
-    minecraft "net.minecraftforge:forge:${minecraft_version}-44.1.8"
+    minecraft "net.minecraftforge:forge:${minecraft_version}-45.0.64"
     implementation project(":Xplat")
     annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
 
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/RenderHelper.java b/Xplat/src/main/java/vazkii/patchouli/client/RenderHelper.java
deleted file mode 100644
index f9e312ae..00000000
--- a/Xplat/src/main/java/vazkii/patchouli/client/RenderHelper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package vazkii.patchouli.client;
-
-import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.PoseStack;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.world.item.ItemStack;
-
-public class RenderHelper {
-	public static void renderItemStackInGui(PoseStack ms, ItemStack stack, int x, int y) {
-		transferMsToGl(ms, () -> Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(stack, x, y));
-	}
-
-	/**
-	 * Temporary shim to allow methods such as
-	 * {@link net.minecraft.client.renderer.entity.ItemRenderer#renderAndDecorateItem}
-	 * to support matrixstack transformations. Hopefully Mojang finishes this migration up...
-	 * Transfers the current CPU matrixstack to the openGL matrix stack, then runs the provided function
-	 * Assumption: the "root" state of the MatrixStack is same as the currently GL state,
-	 * such that multiplying the MatrixStack to the current GL matrix state will get us where we want to be.
-	 * If there have been intervening changes to the GL matrix state since the MatrixStack was constructed, then this
-	 * won't work.
-	 */
-	public static void transferMsToGl(PoseStack ms, Runnable toRun) {
-		PoseStack mvs = RenderSystem.getModelViewStack();
-		mvs.pushPose();
-		mvs.mulPoseMatrix(ms.last().pose());
-		RenderSystem.applyModelViewMatrix();
-		toRun.run();
-		mvs.popPose();
-		RenderSystem.applyModelViewMatrix();
-	}
-}
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java b/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java
index 2257a172..00c71e7b 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java
@@ -12,7 +12,6 @@ import net.minecraft.client.multiplayer.ClientPacketListener;
 import net.minecraft.client.resources.language.I18n;
 import net.minecraft.resources.ResourceLocation;
 
-import vazkii.patchouli.client.RenderHelper;
 import vazkii.patchouli.client.book.ClientBookRegistry;
 import vazkii.patchouli.common.book.Book;
 import vazkii.patchouli.mixin.client.AccessorClientAdvancements;
@@ -90,7 +89,7 @@ public class ClientAdvancements {
 			toastGui.getMinecraft().font.draw(ms, I18n.get(book.name), 30, 7, -11534256);
 			toastGui.getMinecraft().font.draw(ms, I18n.get("patchouli.gui.lexicon.toast.info"), 30, 17, -16777216);
 
-			RenderHelper.renderItemStackInGui(ms, book.getBookItem(), 8, 8);
+			Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(ms, book.getBookItem(), 8, 8);
 
 			return delta >= 5000L ? Toast.Visibility.HIDE : Toast.Visibility.SHOW;
 		}
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java
index 87d3f8b8..ac070e84 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java
@@ -3,12 +3,12 @@ package vazkii.patchouli.client.book;
 import com.mojang.blaze3d.systems.RenderSystem;
 import com.mojang.blaze3d.vertex.PoseStack;
 
+import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.GuiComponent;
 import net.minecraft.resources.ResourceLocation;
 import net.minecraft.world.item.ItemStack;
 
 import vazkii.patchouli.api.PatchouliAPI;
-import vazkii.patchouli.client.RenderHelper;
 import vazkii.patchouli.common.util.ItemStackUtil;
 
 public sealed interface BookIcon permits BookIcon.StackIcon,BookIcon.TextureIcon {
@@ -17,7 +17,7 @@ public sealed interface BookIcon permits BookIcon.StackIcon,BookIcon.TextureIcon
 	record StackIcon(ItemStack stack) implements BookIcon {
 		@Override
 		public void render(PoseStack ms, int x, int y) {
-			RenderHelper.renderItemStackInGui(ms, stack(), x, y);
+			Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(ms, stack(), x, y);
 		}
 	}
 
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java
index dbd97535..2812a3ac 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java
@@ -59,7 +59,7 @@ public class ClientBookRegistry {
 	}
 
 	public void reload(boolean resourcePackBooksOnly) {
-		currentLang = Minecraft.getInstance().getLanguageManager().getSelected().getCode();
+		currentLang = Minecraft.getInstance().getLanguageManager().getSelected();
 		BookRegistry.INSTANCE.reloadContents(resourcePackBooksOnly);
 	}
 
@@ -73,7 +73,7 @@ public class ClientBookRegistry {
 	 */
 	public void displayBookGui(ResourceLocation bookStr, @Nullable ResourceLocation entryId, int page) {
 		Minecraft mc = Minecraft.getInstance();
-		currentLang = mc.getLanguageManager().getSelected().getCode();
+		currentLang = mc.getLanguageManager().getSelected();
 
 		Book book = BookRegistry.INSTANCE.books.get(bookStr);
 
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java
index 4c8a295f..cde369bd 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java
@@ -13,7 +13,6 @@ import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.crafting.Ingredient;
 
 import vazkii.patchouli.api.IComponentRenderContext;
-import vazkii.patchouli.client.RenderHelper;
 import vazkii.patchouli.client.base.PersistentData;
 import vazkii.patchouli.client.base.PersistentData.BookData;
 import vazkii.patchouli.client.base.PersistentData.Bookmark;
@@ -240,10 +239,8 @@ public class GuiBookEntry extends GuiBook implements IComponentRenderContext {
 			return;
 		}
 
-		RenderHelper.transferMsToGl(ms, () -> {
-			Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(stack, x, y);
-			minecraft.getItemRenderer().renderGuiItemDecorations(font, stack, x, y);
-		});
+		Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(ms, stack, x, y);
+		minecraft.getItemRenderer().renderGuiItemDecorations(ms, font, stack, x, y);
 
 		if (isMouseInRelativeRange(mouseX, mouseY, x, y, 16, 16)) {
 			setTooltipStack(stack);
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java
index 99368040..64b497b5 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java
@@ -56,9 +56,9 @@ public abstract class GuiBookEntryList extends GuiBook {
 	protected EditBox createSearchBar() {
 		EditBox field = new EditBox(font, 160, 170, 90, 12, Component.empty());
 		field.setMaxLength(32);
-		//field.setHasBorder(false);
+		field.setBordered(false);
 		field.setCanLoseFocus(false);
-		field.changeFocus(true);
+		field.setFocused(true);
 		return field;
 	}
 
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java
index 6eedc24b..0f7494e3 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java
@@ -40,7 +40,7 @@ public class GuiButtonBook extends Button {
 	}
 
 	@Override
-	public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
+	public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
 		RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
 		GuiBook.drawFromTexture(ms, parent.book, getX(), getY(), u + (isHoveredOrFocused() ? width : 0), v, width, height);
 		if (isHoveredOrFocused()) {
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java
index 6bf62379..929964a9 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java
@@ -31,8 +31,8 @@ public class GuiButtonBookBookmark extends GuiButtonBook {
 	}
 
 	@Override
-	public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
-		super.renderButton(ms, mouseX, mouseY, partialTicks);
+	public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
+		super.renderWidget(ms, mouseX, mouseY, partialTicks);
 
 		BookEntry entry = bookmark == null ? null : bookmark.getEntry(book);
 		if (bookmark != null && entry != null) {
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java
index 4e4c83b1..467ffeb9 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java
@@ -19,8 +19,8 @@ public class GuiButtonBookEye extends GuiButtonBook {
 	}
 
 	@Override
-	public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
-		super.renderButton(ms, mouseX, mouseY, partialTicks);
+	public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
+		super.renderWidget(ms, mouseX, mouseY, partialTicks);
 
 		if (!PersistentData.data.clickedVisualize && (ClientTicker.ticksInGame) % 20 < 10) {
 			parent.getMinecraft().font.drawShadow(ms, "!", getX(), getY(), 0xFF3333);
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java
index b33ca624..10cf8713 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java
@@ -22,7 +22,7 @@ public class GuiButtonBookMarkRead extends GuiButtonBook {
 	}
 
 	@Override
-	public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
+	public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
 		int px = getX() + 1;
 		int py = (int) (getY() + 0.5);
 		GuiBook.drawFromTexture(ms, book, getX(), getY(), 285, 160, 13, 10);
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java
index 6e41a591..1dfc0f73 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java
@@ -41,7 +41,7 @@ public class GuiButtonCategory extends Button {
 	}
 
 	@Override
-	public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
+	public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
 		if (active) {
 			if (isHoveredOrFocused()) {
 				timeHovered = Math.min(ANIM_TIME, timeHovered + ClientTicker.delta);
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java
index d059df35..e00e205d 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java
@@ -30,7 +30,7 @@ public class GuiButtonEntry extends Button {
 	}
 
 	@Override
-	public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
+	public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
 		if (active) {
 			if (isHoveredOrFocused()) {
 				timeHovered = Math.min(ANIM_TIME, timeHovered + ClientTicker.delta);
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageCrafting.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageCrafting.java
index 4b3aa059..42aed2fd 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageCrafting.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageCrafting.java
@@ -3,6 +3,7 @@ package vazkii.patchouli.client.book.page;
 import com.mojang.blaze3d.systems.RenderSystem;
 import com.mojang.blaze3d.vertex.PoseStack;
 
+import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.GuiComponent;
 import net.minecraft.core.NonNullList;
 import net.minecraft.network.chat.Component;
@@ -11,6 +12,7 @@ import net.minecraft.world.item.crafting.Ingredient;
 import net.minecraft.world.item.crafting.Recipe;
 import net.minecraft.world.item.crafting.RecipeType;
 import net.minecraft.world.item.crafting.ShapedRecipe;
+import net.minecraft.world.level.Level;
 
 import vazkii.patchouli.client.book.gui.GuiBook;
 import vazkii.patchouli.client.book.page.abstr.PageDoubleRecipeRegistry;
@@ -23,6 +25,10 @@ public class PageCrafting extends PageDoubleRecipeRegistry<Recipe<?>> {
 
 	@Override
 	protected void drawRecipe(PoseStack ms, Recipe<?> recipe, int recipeX, int recipeY, int mouseX, int mouseY, boolean second) {
+		Level level = Minecraft.getInstance().level;
+		if (level == null)
+			return;
+
 		RenderSystem.setShaderTexture(0, book.craftingTexture);
 		RenderSystem.enableBlend();
 		GuiComponent.blit(ms, recipeX - 2, recipeY - 2, 0, 0, 100, 62, 128, 256);
@@ -39,7 +45,7 @@ public class PageCrafting extends PageDoubleRecipeRegistry<Recipe<?>> {
 
 		parent.drawCenteredStringNoShadow(ms, getTitle(second).getVisualOrderText(), GuiBook.PAGE_WIDTH / 2, recipeY - 10, book.headerColor);
 
-		parent.renderItemStack(ms, recipeX + 79, recipeY + 22, mouseX, mouseY, recipe.getResultItem());
+		parent.renderItemStack(ms, recipeX + 79, recipeY + 22, mouseX, mouseY, recipe.getResultItem(level.registryAccess()));
 
 		NonNullList<Ingredient> ingredients = recipe.getIngredients();
 		int wrap = 3;
@@ -61,11 +67,12 @@ public class PageCrafting extends PageDoubleRecipeRegistry<Recipe<?>> {
 
 	@Override
 	protected ItemStack getRecipeOutput(Recipe<?> recipe) {
-		if (recipe == null) {
+		Level level = Minecraft.getInstance().level;
+		if (recipe == null || level == null) {
 			return ItemStack.EMPTY;
 		}
 
-		return recipe.getResultItem();
+		return recipe.getResultItem(level.registryAccess());
 	}
 
 }
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageSmithing.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageSmithing.java
index 9a8a571f..348f2e4b 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageSmithing.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageSmithing.java
@@ -3,23 +3,29 @@ package vazkii.patchouli.client.book.page;
 import com.mojang.blaze3d.systems.RenderSystem;
 import com.mojang.blaze3d.vertex.PoseStack;
 
+import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.GuiComponent;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.crafting.RecipeType;
-import net.minecraft.world.item.crafting.UpgradeRecipe;
+import net.minecraft.world.item.crafting.SmithingRecipe;
+import net.minecraft.world.level.Level;
 
 import vazkii.patchouli.client.book.gui.GuiBook;
 import vazkii.patchouli.client.book.page.abstr.PageDoubleRecipeRegistry;
 import vazkii.patchouli.mixin.AccessorSmithingRecipe;
 
-public class PageSmithing extends PageDoubleRecipeRegistry<UpgradeRecipe> {
+public class PageSmithing extends PageDoubleRecipeRegistry<SmithingRecipe> {
 
 	public PageSmithing() {
 		super(RecipeType.SMITHING);
 	}
 
 	@Override
-	protected void drawRecipe(PoseStack ms, UpgradeRecipe recipe, int recipeX, int recipeY, int mouseX, int mouseY, boolean second) {
+	protected void drawRecipe(PoseStack ms, SmithingRecipe recipe, int recipeX, int recipeY, int mouseX, int mouseY, boolean second) {
+		Level level = Minecraft.getInstance().level;
+		if (level == null)
+			return;
+
 		RenderSystem.setShaderTexture(0, book.craftingTexture);
 		RenderSystem.enableBlend();
 		GuiComponent.blit(ms, recipeX, recipeY, 11, 135, 96, 43, 128, 256);
@@ -28,16 +34,17 @@ public class PageSmithing extends PageDoubleRecipeRegistry<UpgradeRecipe> {
 		parent.renderIngredient(ms, recipeX + 4, recipeY + 4, mouseX, mouseY, ((AccessorSmithingRecipe) recipe).getBase());
 		parent.renderIngredient(ms, recipeX + 4, recipeY + 23, mouseX, mouseY, ((AccessorSmithingRecipe) recipe).getAddition());
 		parent.renderItemStack(ms, recipeX + 40, recipeY + 13, mouseX, mouseY, recipe.getToastSymbol());
-		parent.renderItemStack(ms, recipeX + 76, recipeY + 13, mouseX, mouseY, recipe.getResultItem());
+		parent.renderItemStack(ms, recipeX + 76, recipeY + 13, mouseX, mouseY, recipe.getResultItem(level.registryAccess()));
 	}
 
 	@Override
-	protected ItemStack getRecipeOutput(UpgradeRecipe recipe) {
-		if (recipe == null) {
+	protected ItemStack getRecipeOutput(SmithingRecipe recipe) {
+		Level level = Minecraft.getInstance().level;
+		if (recipe == null || level == null) {
 			return ItemStack.EMPTY;
 		}
 
-		return recipe.getResultItem();
+		return recipe.getResultItem(level.registryAccess());
 	}
 
 	@Override
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java
index 163aa64c..989c6a3b 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java
@@ -6,6 +6,7 @@ import net.minecraft.resources.ResourceLocation;
 import net.minecraft.world.item.crafting.Recipe;
 import net.minecraft.world.item.crafting.RecipeManager;
 import net.minecraft.world.item.crafting.RecipeType;
+import net.minecraft.world.level.Level;
 
 import vazkii.patchouli.api.PatchouliAPI;
 import vazkii.patchouli.client.book.BookContentsBuilder;
@@ -31,7 +32,8 @@ public abstract class PageDoubleRecipeRegistry<T extends Recipe<?>> extends Page
 
 	@Override
 	protected T loadRecipe(BookContentsBuilder builder, BookEntry entry, ResourceLocation res) {
-		if (res == null) {
+		Level level = Minecraft.getInstance().level;
+		if (res == null || level == null) {
 			return null;
 		}
 
@@ -41,7 +43,7 @@ public abstract class PageDoubleRecipeRegistry<T extends Recipe<?>> extends Page
 		}
 
 		if (tempRecipe != null) {
-			entry.addRelevantStack(builder, tempRecipe.getResultItem(), pageNum);
+			entry.addRelevantStack(builder, tempRecipe.getResultItem(level.registryAccess()), pageNum);
 			return tempRecipe;
 		}
 
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageSimpleProcessingRecipe.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageSimpleProcessingRecipe.java
index ddaddb33..2f26ad81 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageSimpleProcessingRecipe.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageSimpleProcessingRecipe.java
@@ -3,10 +3,12 @@ package vazkii.patchouli.client.book.page.abstr;
 import com.mojang.blaze3d.systems.RenderSystem;
 import com.mojang.blaze3d.vertex.PoseStack;
 
+import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.GuiComponent;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.crafting.Recipe;
 import net.minecraft.world.item.crafting.RecipeType;
+import net.minecraft.world.level.Level;
 
 import vazkii.patchouli.client.book.gui.GuiBook;
 
@@ -18,6 +20,10 @@ public abstract class PageSimpleProcessingRecipe<T extends Recipe<?>> extends Pa
 
 	@Override
 	protected void drawRecipe(PoseStack ms, T recipe, int recipeX, int recipeY, int mouseX, int mouseY, boolean second) {
+		Level level = Minecraft.getInstance().level;
+		if (level == null)
+			return;
+
 		RenderSystem.setShaderTexture(0, book.craftingTexture);
 		RenderSystem.enableBlend();
 		GuiComponent.blit(ms, recipeX, recipeY, 11, 71, 96, 24, 128, 256);
@@ -25,16 +31,17 @@ public abstract class PageSimpleProcessingRecipe<T extends Recipe<?>> extends Pa
 
 		parent.renderIngredient(ms, recipeX + 4, recipeY + 4, mouseX, mouseY, recipe.getIngredients().get(0));
 		parent.renderItemStack(ms, recipeX + 40, recipeY + 4, mouseX, mouseY, recipe.getToastSymbol());
-		parent.renderItemStack(ms, recipeX + 76, recipeY + 4, mouseX, mouseY, recipe.getResultItem());
+		parent.renderItemStack(ms, recipeX + 76, recipeY + 4, mouseX, mouseY, recipe.getResultItem(level.registryAccess()));
 	}
 
 	@Override
 	protected ItemStack getRecipeOutput(T recipe) {
-		if (recipe == null) {
+		Level level = Minecraft.getInstance().level;
+		if (recipe == null || level == null) {
 			return ItemStack.EMPTY;
 		}
 
-		return recipe.getResultItem();
+		return recipe.getResultItem(level.registryAccess());
 	}
 
 	@Override
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java b/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java
index 3acd99cd..58f10861 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java
@@ -6,6 +6,7 @@ import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.crafting.Ingredient;
 import net.minecraft.world.item.crafting.Recipe;
 import net.minecraft.world.item.crafting.RecipeManager;
+import net.minecraft.world.level.Level;
 
 import vazkii.patchouli.api.IComponentProcessor;
 import vazkii.patchouli.api.IVariable;
@@ -25,6 +26,9 @@ public class RecipeTestProcessor implements IComponentProcessor {
 
 	@Override
 	public IVariable process(String key) {
+		Level level = Minecraft.getInstance().level;
+		if (level == null)
+			return null;
 		if (key.startsWith("item")) {
 			int index = Integer.parseInt(key.substring(4)) - 1;
 			Ingredient ingredient = recipe.getIngredients().get(index);
@@ -33,12 +37,12 @@ public class RecipeTestProcessor implements IComponentProcessor {
 
 			return IVariable.from(stack);
 		} else if (key.equals("text")) {
-			ItemStack out = recipe.getResultItem();
+			ItemStack out = recipe.getResultItem(level.registryAccess());
 			return IVariable.wrap(out.getCount() + "x$(br)" + out.getHoverName());
 		} else if (key.equals("icount")) {
-			return IVariable.wrap(recipe.getResultItem().getCount());
+			return IVariable.wrap(recipe.getResultItem(level.registryAccess()).getCount());
 		} else if (key.equals("iname")) {
-			return IVariable.wrap(recipe.getResultItem().getHoverName().getString());
+			return IVariable.wrap(recipe.getResultItem(level.registryAccess()).getHoverName().getString());
 		}
 
 		return null;
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/text/TextLayouter.java b/Xplat/src/main/java/vazkii/patchouli/client/book/text/TextLayouter.java
index ece59dd6..6559e602 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/book/text/TextLayouter.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/book/text/TextLayouter.java
@@ -2,7 +2,6 @@ package vazkii.patchouli.client.book.text;
 
 import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.Font;
-import net.minecraft.client.resources.language.LanguageInfo;
 import net.minecraft.network.chat.Component;
 
 import vazkii.patchouli.api.PatchouliConfigAccess;
@@ -103,15 +102,7 @@ public class TextLayouter {
 	// a paragraph is a series of spans without explicit line break
 	private void layoutParagraph(List<Span> paragraph) {
 		String text = toString(paragraph);
-		// todo fabric is there a helper to do this?
-		LanguageInfo language = Minecraft.getInstance().getLanguageManager().getSelected();
-		Locale locale;
-		String[] splitLangCode = language.getName().split("_", 2);
-		if (splitLangCode.length == 1) {
-			locale = new Locale(language.getCode());
-		} else {
-			locale = new Locale(splitLangCode[0], splitLangCode[1]);
-		}
+		Locale locale = new Locale(Minecraft.getInstance().getLanguageManager().getSelected());
 		BreakIterator iterator = BreakIterator.getLineInstance(locale);
 		iterator.setText(text);
 		lineStart = 0;
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java b/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java
index b701cfae..fa97d8cf 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java
@@ -11,7 +11,6 @@ import net.minecraft.resources.ResourceLocation;
 import net.minecraft.world.item.ItemStack;
 
 import vazkii.patchouli.api.PatchouliAPI;
-import vazkii.patchouli.client.RenderHelper;
 import vazkii.patchouli.client.book.BookContents;
 import vazkii.patchouli.client.book.EntryDisplayState;
 import vazkii.patchouli.client.book.gui.GuiBook;
@@ -30,7 +29,7 @@ public class GuiButtonInventoryBook extends Button {
 	}
 
 	@Override
-	public void renderButton(PoseStack ms, int mouseX, int mouseY, float pticks) {
+	public void renderWidget(PoseStack ms, int mouseX, int mouseY, float pticks) {
 		Minecraft mc = Minecraft.getInstance();
 		RenderSystem.setShaderTexture(0, new ResourceLocation(PatchouliAPI.MOD_ID, "textures/gui/inventory_button.png"));
 		RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
@@ -39,7 +38,7 @@ public class GuiButtonInventoryBook extends Button {
 		GuiComponent.blit(ms, getX(), getY(), (hovered ? 20 : 0), 0, width, height, 64, 64);
 
 		ItemStack stack = book.getBookItem();
-		RenderHelper.renderItemStackInGui(ms, stack, getX() + 2, getY() + 2);
+		Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(ms, stack, getX() + 2, getY() + 2);
 
 		EntryDisplayState readState = book.getContents().getReadState();
 		if (readState.hasIcon && readState.showInInventory) {
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java b/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java
index 81b6a46c..b61c81b4 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java
@@ -18,7 +18,6 @@ import net.minecraft.world.level.block.state.BlockState;
 import net.minecraft.world.phys.BlockHitResult;
 import net.minecraft.world.phys.HitResult;
 
-import vazkii.patchouli.client.RenderHelper;
 import vazkii.patchouli.client.book.BookEntry;
 import vazkii.patchouli.common.book.Book;
 import vazkii.patchouli.common.util.ItemStackUtil;
@@ -47,7 +46,7 @@ public class BookRightClickHandler {
 						ms.pushPose();
 						ms.translate(0, 0, 10);
 						ms.scale(0.5F, 0.5F, 1);
-						RenderHelper.renderItemStackInGui(ms, bookStack, (x + 8) * 2, (y + 8) * 2);
+						Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(ms, bookStack, (x + 8) * 2, (y + 8) * 2);
 						ms.popPose();
 
 						mc.font.draw(ms, entry.getName(), x + 18, y + 3, 0xFFFFFF);
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java b/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java
index 8ea1adf8..8336af52 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java
@@ -36,7 +36,6 @@ import org.joml.Matrix4f;
 
 import vazkii.patchouli.api.IMultiblock;
 import vazkii.patchouli.api.PatchouliAPI;
-import vazkii.patchouli.client.RenderHelper;
 import vazkii.patchouli.client.base.ClientTicker;
 import vazkii.patchouli.client.base.PersistentData.Bookmark;
 import vazkii.patchouli.common.multiblock.StateMatcher;
@@ -140,7 +139,7 @@ public class MultiblockVisualizationHandler {
 
 						if (!stack.isEmpty()) {
 							mc.font.drawShadow(ms, stack.getHoverName(), left + 20, top + height + 8, 0xFFFFFF);
-							RenderHelper.renderItemStackInGui(ms, stack, left, top + height + 2);
+							Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(ms, stack, left, top + height + 2);
 						}
 					} catch (Exception ignored) {}
 				}
@@ -319,7 +318,6 @@ public class MultiblockVisualizationHandler {
 		float f5 = (float) (endColor >> 16 & 255) / 255.0F;
 		float f6 = (float) (endColor >> 8 & 255) / 255.0F;
 		float f7 = (float) (endColor & 255) / 255.0F;
-		RenderSystem.disableTexture();
 		RenderSystem.enableBlend();
 		RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
 		Tesselator tessellator = Tesselator.getInstance();
@@ -332,7 +330,6 @@ public class MultiblockVisualizationHandler {
 		bufferbuilder.vertex(mat, right, bottom, 0).color(f5, f6, f7, f4).endVertex();
 		tessellator.end();
 		RenderSystem.disableBlend();
-		RenderSystem.enableTexture();
 	}
 
 	/**
diff --git a/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java b/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java
index 0710848e..de6d2719 100644
--- a/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java
+++ b/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java
@@ -18,7 +18,6 @@ import net.minecraft.world.item.ItemStack;
 
 import org.lwjgl.opengl.GL11;
 
-import vazkii.patchouli.client.RenderHelper;
 import vazkii.patchouli.client.base.ClientTicker;
 import vazkii.patchouli.client.book.BookEntry;
 import vazkii.patchouli.client.book.ClientBookRegistry;
@@ -73,7 +72,6 @@ public class TooltipHandler {
 					float requiredTime = PatchouliConfig.get().quickLookupTime();
 					float angles = lexiconLookupTime / requiredTime * 360F;
 
-					RenderSystem.disableTexture();
 					RenderSystem.enableBlend();
 					RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
 
@@ -92,7 +90,6 @@ public class TooltipHandler {
 					Tesselator.getInstance().end();
 
 					RenderSystem.disableBlend();
-					RenderSystem.enableTexture();
 
 					if (lexiconLookupTime >= requiredTime) {
 						mc.player.getInventory().selected = lexSlot;
@@ -103,9 +100,11 @@ public class TooltipHandler {
 					lexiconLookupTime = 0F;
 				}
 
-				mc.getItemRenderer().blitOffset = 300;
-				RenderHelper.renderItemStackInGui(ms, lexiconStack, x, tooltipY);
-				mc.getItemRenderer().blitOffset = 0;
+				ms.pushPose();
+				ms.translate(0, 0, 300);
+				Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(ms, lexiconStack, x, tooltipY);
+				ms.popPose();
 
 				ms.pushPose();
 				ms.translate(0, 0, 500);
diff --git a/Xplat/src/main/java/vazkii/patchouli/common/handler/LecternEventHandler.java b/Xplat/src/main/java/vazkii/patchouli/common/handler/LecternEventHandler.java
index 5d0b0229..dfc62acf 100644
--- a/Xplat/src/main/java/vazkii/patchouli/common/handler/LecternEventHandler.java
+++ b/Xplat/src/main/java/vazkii/patchouli/common/handler/LecternEventHandler.java
@@ -51,7 +51,7 @@ public class LecternEventHandler {
 	private static void takeBook(Player player, LecternBlockEntity tileEntity) {
 		ItemStack itemstack = tileEntity.getBook();
 		tileEntity.setBook(ItemStack.EMPTY);
-		LecternBlock.resetBookState(tileEntity.getLevel(), tileEntity.getBlockPos(), tileEntity.getBlockState(), false);
+		LecternBlock.resetBookState(player, tileEntity.getLevel(), tileEntity.getBlockPos(), tileEntity.getBlockState(), false);
 		if (!player.getInventory().add(itemstack)) {
 			player.drop(itemstack, false);
 		}
diff --git a/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java b/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java
index c96518a2..4fa8a124 100644
--- a/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java
+++ b/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java
@@ -1,11 +1,13 @@
 package vazkii.patchouli.common.recipe;
 
+import net.minecraft.client.Minecraft;
 import net.minecraft.resources.ResourceLocation;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.crafting.CraftingBookCategory;
 import net.minecraft.world.item.crafting.Recipe;
 import net.minecraft.world.item.crafting.RecipeSerializer;
 import net.minecraft.world.item.crafting.ShapedRecipe;
+import net.minecraft.world.level.Level;
 
 import vazkii.patchouli.api.PatchouliAPI;
 
@@ -22,10 +24,13 @@ public class ShapedBookRecipe extends ShapedRecipe {
 	}
 
 	static ItemStack getOutputBook(Recipe<?> compose, ResourceLocation outputBook) {
+		Level level = Minecraft.getInstance().level;
+		if (level == null)
+			return null;
 		if (outputBook != null) {
 			return PatchouliAPI.get().getBookStack(outputBook);
 		}
-		return compose.getResultItem();
+		return compose.getResultItem(level.registryAccess());
 	}
 
 	@Override
diff --git a/Xplat/src/main/java/vazkii/patchouli/mixin/AccessorSmithingRecipe.java b/Xplat/src/main/java/vazkii/patchouli/mixin/AccessorSmithingRecipe.java
index 00492a57..04ecaf70 100644
--- a/Xplat/src/main/java/vazkii/patchouli/mixin/AccessorSmithingRecipe.java
+++ b/Xplat/src/main/java/vazkii/patchouli/mixin/AccessorSmithingRecipe.java
@@ -1,12 +1,13 @@
 package vazkii.patchouli.mixin;
 
 import net.minecraft.world.item.crafting.Ingredient;
-import net.minecraft.world.item.crafting.UpgradeRecipe;
+import net.minecraft.world.item.crafting.LegacyUpgradeRecipe;
 
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.gen.Accessor;
 
-@Mixin(UpgradeRecipe.class)
+@SuppressWarnings("deprecated")
+@Mixin(LegacyUpgradeRecipe.class)
 public interface AccessorSmithingRecipe {
 	@Accessor("base")
 	Ingredient getBase();
diff --git a/gradle.properties b/gradle.properties
index 8351a973..78d22989 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,7 +7,7 @@ org.gradle.jvmargs=-Xmx1G \
   --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
   --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
 
-minecraft_version=1.19.3
+minecraft_version=1.19.4
 build_number=79
 group=vazkii.patchouli
 mod_name=Patchouli
-- 
2.39.2 (Apple Git-143)
Details
Message ID
<87pm6tqqrt.fsf@vincent-lee.net>
In-Reply-To
<20230521201817.22594-1-theArtemisSystem@gmail.com> (view parent)
DKIM signature
missing
Download raw message
This patch seems malformed somehow, git am and sl import both don't
like, and Sourcehut seems to not recognize it. It appears the last hunk
of TooltipHandler is missing a line somehow.

However, this seems like it works. Ok for me to commit.
There's a couple cleanups I want to do before releasing, and the test
book creative tab stuff needs to be fixed, but I can do that in tree
after you commit this.

Artemis System <theartemissystem@gmail.com> writes:

> ---
> There is something wrong with the next/prev buttons, sometimes they seem to
> "get stuck" and their tooltip always renders. I didn't have time to look into
> it. In general not thoroughly tested either

You probably started selecting things with TAB, which is a vanilla
feature. The selected thing will stay in its hover-state. I didn't have
this issue when testing this diff.

> I'm not sure if the recipe mapping tooltip renders correctly either, the test
> book didn't seem to have any set up or it just wasn't working.

Seems to work for me.

> So, this isn't a very rigid port, but it's enough for other mods to depend
> on i guess, if they need to start updating.
Details
Message ID
<1587A3FC-08E7-4E6C-8DF4-5D49038E2338@gmail.com>
In-Reply-To
<87pm6tqqrt.fsf@vincent-lee.net> (view parent)
DKIM signature
missing
Download raw message
That makes a lot of sense. i noticed a todo in the code that i deleted in the mail edit stage, and i didn't think removing the line would break anything since i've heard of others' adventures with manually editing patches. i'll just push it myself since i see you've invited me to collaborate

> On 22 May 2023, at 00:11, Vincent Lee <vincent@vincent-lee.net> wrote:
> 
> ´╗┐This patch seems malformed somehow, git am and sl import both don't
> like, and Sourcehut seems to not recognize it. It appears the last hunk
> of TooltipHandler is missing a line somehow.
> 
> However, this seems like it works. Ok for me to commit.
> There's a couple cleanups I want to do before releasing, and the test
> book creative tab stuff needs to be fixed, but I can do that in tree
> after you commit this.
> 
> Artemis System <theartemissystem@gmail.com> writes:
> 
>> ---
>> There is something wrong with the next/prev buttons, sometimes they seem to
>> "get stuck" and their tooltip always renders. I didn't have time to look into
>> it. In general not thoroughly tested either
> 
> You probably started selecting things with TAB, which is a vanilla
> feature. The selected thing will stay in its hover-state. I didn't have
> this issue when testing this diff.
> 
>> I'm not sure if the recipe mapping tooltip renders correctly either, the test
>> book didn't seem to have any set up or it just wasn't working.
> 
> Seems to work for me.
> 
>> So, this isn't a very rigid port, but it's enough for other mods to depend
>> on i guess, if they need to start updating.
Reply to thread Export thread (mbox)