From 5a4dfcd276700fa2fe00ff1a029b1fa695e14f2e Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Sun, 17 Nov 2024 21:08:07 +0100 Subject: [PATCH] Use correct buffer source for rendering --- .../rei/api/client/entry/renderer/BatchedEntryRenderer.java | 5 ++--- fabric/src/main/resources/roughlyenoughitems.accessWidener | 3 ++- forge/src/main/resources/META-INF/accesstransformer.cfg | 3 ++- neoforge/src/main/resources/META-INF/accesstransformer.cfg | 3 +-- .../impl/client/gui/widget/BatchedEntryRendererManager.java | 4 +--- .../rei/plugin/client/entry/FluidEntryDefinition.java | 2 +- .../rei/plugin/client/entry/ItemEntryDefinition.java | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java index eaf030ccf..2aba4ba67 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java @@ -28,7 +28,6 @@ import me.shedaniel.rei.api.common.entry.EntryStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; @@ -107,7 +106,7 @@ default void render(EntryStack entry, GuiGraphics graphics, Rectangle bounds, graphics.pose().last().normal().set(newStack.last().normal()); E data = getExtraData(entry); startBatch(entry, data, graphics, delta); - MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); + MultiBufferSource.BufferSource immediate = graphics.bufferSource; renderBase(entry, data, graphics, immediate, bounds, mouseX, mouseY, delta); immediate.endBatch(); renderOverlay(entry, data, graphics, immediate, bounds, mouseX, mouseY, delta); @@ -115,4 +114,4 @@ default void render(EntryStack entry, GuiGraphics graphics, Rectangle bounds, endBatch(entry, data, graphics, delta); graphics.pose().popPose(); } -} \ No newline at end of file +} diff --git a/fabric/src/main/resources/roughlyenoughitems.accessWidener b/fabric/src/main/resources/roughlyenoughitems.accessWidener index a960d8311..3d7dc66d6 100644 --- a/fabric/src/main/resources/roughlyenoughitems.accessWidener +++ b/fabric/src/main/resources/roughlyenoughitems.accessWidener @@ -41,4 +41,5 @@ accessible method net/minecraft/world/item/crafting/SingleItemRecipe result ()Ln accessible field net/minecraft/world/item/crafting/ShapedRecipe result Lnet/minecraft/world/item/ItemStack; accessible field net/minecraft/world/item/crafting/ShapelessRecipe result Lnet/minecraft/world/item/ItemStack; accessible field net/minecraft/client/gui/screens/inventory/AbstractRecipeBookScreen recipeBookComponent Lnet/minecraft/client/gui/screens/recipebook/RecipeBookComponent; -accessible method net/minecraft/client/gui/GuiGraphics innerBlit (Ljava/util/function/Function;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V \ No newline at end of file +accessible method net/minecraft/client/gui/GuiGraphics innerBlit (Ljava/util/function/Function;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V +accessible field net/minecraft/client/gui/GuiGraphics bufferSource Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource; diff --git a/forge/src/main/resources/META-INF/accesstransformer.cfg b/forge/src/main/resources/META-INF/accesstransformer.cfg index 6eb5af3b2..6ec98af95 100644 --- a/forge/src/main/resources/META-INF/accesstransformer.cfg +++ b/forge/src/main/resources/META-INF/accesstransformer.cfg @@ -49,4 +49,5 @@ public-f net.minecraft.client.gui.font.CodepointMap f_283773_ # blockConstructor public net.minecraft.world.item.CreativeModeTab f_256824_ # displayItemsGenerator public net.minecraft.world.item.CreativeModeTab$ItemDisplayBuilder public net.minecraft.client.multiplayer.ClientLevel f_104561_ # connection -public net.minecraft.client.multiplayer.MultiPlayerGameMode f_105190_ # connection \ No newline at end of file +public net.minecraft.client.multiplayer.MultiPlayerGameMode f_105190_ # connection +public net.minecraft.client.gui.GuiGraphics f_279627_ # bufferSource diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg index a641f1d56..070e182a8 100644 --- a/neoforge/src/main/resources/META-INF/accesstransformer.cfg +++ b/neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -52,5 +52,4 @@ public net.minecraft.world.item.crafting.ShapedRecipe result public net.minecraft.world.item.crafting.ShapelessRecipe result public net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen recipeBookComponent public net.minecraft.client.gui.GuiGraphics innerBlit(Ljava/util/function/Function;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V - - +public net.minecraft.client.gui.GuiGraphics bufferSource diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java index c14ca5923..f13ea1311 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java @@ -26,7 +26,6 @@ import com.google.common.collect.AbstractIterator; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -37,7 +36,6 @@ import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.util.CrashReportUtils; import net.minecraft.CrashReport; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import org.apache.commons.lang3.mutable.MutableInt; @@ -178,7 +176,7 @@ private static void renderBatched(boolean debugTime, Mut graphics.pose().last().pose().set(newStack.last().pose()); graphics.pose().last().normal().set(newStack.last().normal()); long l = debugTime ? System.nanoTime() : 0; - MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); + MultiBufferSource.BufferSource immediate = graphics.bufferSource; int i = 0; for (T entry : entries) { try { diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java index ae94f80dc..4480cda5b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java @@ -271,7 +271,7 @@ public void render(EntryStack entry, GuiGraphics graphics, Rectangle if (sprite == null) return; int color = FluidStackHooks.getColor(stack); - MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); + MultiBufferSource.BufferSource immediate = graphics.bufferSource; SpriteRenderer.beginPass() .setup(immediate, RenderType.solid()) diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java index 6200ce8cd..a2c046e9f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java @@ -265,7 +265,7 @@ public void render(EntryStack entry, GuiGraphics graphics, Rectangle graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); graphics.pose().mulPose(new Matrix4f().scaling(1.0F, -1.0F, 1.0F)); graphics.pose().scale(bounds.getWidth(), bounds.getHeight(), (bounds.getWidth() + bounds.getHeight()) / 2.0F); - MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); + MultiBufferSource.BufferSource immediate = graphics.bufferSource; Minecraft.getInstance().getItemRenderer().render(value, ItemDisplayContext.GUI, false, graphics.pose(), immediate, ITEM_LIGHT, OverlayTexture.NO_OVERLAY, model); immediate.endBatch();