Skip to content

Commit

Permalink
Use correct buffer source for rendering (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC authored Dec 6, 2024
1 parent 7343b3c commit 18baa61
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -107,12 +106,12 @@ default void render(EntryStack<T> 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);
immediate.endBatch();
endBatch(entry, data, graphics, delta);
graphics.pose().popPose();
}
}
}
3 changes: 2 additions & 1 deletion fabric/src/main/resources/roughlyenoughitems.accessWidener
Original file line number Diff line number Diff line change
Expand Up @@ -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
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;
3 changes: 2 additions & 1 deletion forge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
public net.minecraft.client.multiplayer.MultiPlayerGameMode f_105190_ # connection
public net.minecraft.client.gui.GuiGraphics f_279627_ # bufferSource
3 changes: 1 addition & 2 deletions neoforge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -178,7 +176,7 @@ private static <T extends EntryWidget> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void render(EntryStack<FluidStack> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void render(EntryStack<ItemStack> 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();
Expand Down

0 comments on commit 18baa61

Please sign in to comment.