aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/plugin/client
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2023-05-28 04:09:32 +0800
committershedaniel <daniel@shedaniel.me>2023-05-28 04:09:32 +0800
commita35425108d9813f64779b519fedd4744a7eb6072 (patch)
treee6cb499ea73182955527205cdec053abf7d74012 /runtime/src/main/java/me/shedaniel/rei/plugin/client
parente11f3e6de3d0d3708061b765fb77dee0746aaf83 (diff)
downloadRoughlyEnoughItems-a35425108d9813f64779b519fedd4744a7eb6072.tar.gz
RoughlyEnoughItems-a35425108d9813f64779b519fedd4744a7eb6072.tar.bz2
RoughlyEnoughItems-a35425108d9813f64779b519fedd4744a7eb6072.zip
Update to 1.20-pre6
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/plugin/client')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java25
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java50
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java11
3 files changed, 41 insertions, 45 deletions
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 ea873a124..98889258d 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
@@ -25,14 +25,12 @@ package me.shedaniel.rei.plugin.client.entry;
import com.google.common.base.Suppliers;
import com.google.common.collect.Lists;
-import com.mojang.blaze3d.vertex.PoseStack;
import dev.architectury.fluid.FluidStack;
import dev.architectury.hooks.fluid.FluidStackHooks;
import dev.architectury.platform.Platform;
import dev.architectury.utils.Env;
import dev.architectury.utils.EnvExecutor;
import me.shedaniel.math.Rectangle;
-import me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer;
import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer;
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
@@ -51,6 +49,7 @@ import net.minecraft.ChatFormatting;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
@@ -219,7 +218,7 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS
}
@Environment(EnvType.CLIENT)
- public static class FluidEntryRenderer extends AbstractEntryRenderer<FluidStack> implements BatchedEntryRenderer<FluidStack, TextureAtlasSprite> {
+ public static class FluidEntryRenderer implements BatchedEntryRenderer<FluidStack, TextureAtlasSprite> {
private static final Supplier<TextureAtlasSprite> MISSING_SPRITE = Suppliers.memoize(() -> {
TextureAtlas atlas = Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS);
return atlas.getSprite(MissingTextureAtlasSprite.getLocation());
@@ -242,10 +241,10 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS
}
@Override
- public void startBatch(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, PoseStack matrices, float delta) {}
+ public void startBatch(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, float delta) {}
@Override
- public void renderBase(EntryStack<FluidStack> entry, TextureAtlasSprite sprite, PoseStack matrices, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ public void renderBase(EntryStack<FluidStack> entry, TextureAtlasSprite sprite, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {
TextureAtlasSprite s = sprite == null ? missingTexture() : sprite;
SpriteRenderer.beginPass()
.setup(immediate, RenderType.solid())
@@ -254,22 +253,22 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS
.light(0x00f000f0)
.overlay(OverlayTexture.NO_OVERLAY)
.alpha(0xff)
- .normal(matrices.last().normal(), 0, 0, 0)
- .position(matrices.last().pose(), bounds.x, bounds.getMaxY() - bounds.height * Mth.clamp(entry.get(EntryStack.Settings.FLUID_RENDER_RATIO), 0, 1), bounds.getMaxX(), bounds.getMaxY(), entry.getZ())
+ .normal(graphics.pose().last().normal(), 0, 0, 0)
+ .position(graphics.pose().last().pose(), bounds.x, bounds.getMaxY() - bounds.height * Mth.clamp(entry.get(EntryStack.Settings.FLUID_RENDER_RATIO), 0, 1), bounds.getMaxX(), bounds.getMaxY(), 0)
.next(s.atlasLocation());
}
@Override
- public void afterBase(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, PoseStack matrices, float delta) {}
+ public void afterBase(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, float delta) {}
@Override
- public void renderOverlay(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, PoseStack matrices, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {}
+ public void renderOverlay(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {}
@Override
- public void endBatch(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, PoseStack matrices, float delta) {}
+ public void endBatch(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, float delta) {}
@Override
- public void render(EntryStack<FluidStack> entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ public void render(EntryStack<FluidStack> entry, GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) {
FluidStack stack = entry.getValue();
if (stack.isEmpty()) return;
TextureAtlasSprite sprite = FluidStackHooks.getStillTexture(stack);
@@ -285,8 +284,8 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS
.light(0x00f000f0)
.overlay(OverlayTexture.NO_OVERLAY)
.alpha(0xff)
- .normal(matrices.last().normal(), 0, 0, 0)
- .position(matrices.last().pose(), bounds.x, bounds.getMaxY() - bounds.height * Mth.clamp(entry.get(EntryStack.Settings.FLUID_RENDER_RATIO), 0, 1), bounds.getMaxX(), bounds.getMaxY(), entry.getZ())
+ .normal(graphics.pose().last().normal(), 0, 0, 0)
+ .position(graphics.pose().last().pose(), bounds.x, bounds.getMaxY() - bounds.height * Mth.clamp(entry.get(EntryStack.Settings.FLUID_RENDER_RATIO), 0, 1), bounds.getMaxX(), bounds.getMaxY(), 0)
.next(InventoryMenu.BLOCK_ATLAS);
immediate.endBatch();
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 f27b30c15..e30e800f1 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
@@ -34,7 +34,6 @@ import dev.architectury.utils.EnvExecutor;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import it.unimi.dsi.fastutil.objects.ReferenceSet;
import me.shedaniel.math.Rectangle;
-import me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer;
import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer;
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
@@ -51,6 +50,7 @@ import net.fabricmc.api.Environment;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.TextureAtlas;
@@ -243,7 +243,7 @@ public class ItemEntryDefinition implements EntryDefinition<ItemStack>, EntrySer
}
@Environment(EnvType.CLIENT)
- public class ItemEntryRenderer extends AbstractEntryRenderer<ItemStack> implements BatchedEntryRenderer<ItemStack, BakedModel> {
+ public class ItemEntryRenderer implements BatchedEntryRenderer<ItemStack, BakedModel> {
private static final float SCALE = 20.0F;
public static final int ITEM_LIGHT = 0xf000f0;
@@ -254,28 +254,28 @@ public class ItemEntryDefinition implements EntryDefinition<ItemStack>, EntrySer
}
@Override
- public void render(EntryStack<ItemStack> entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ public void render(EntryStack<ItemStack> entry, GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) {
BakedModel model = getExtraData(entry);
setupGL(entry, model);
if (!entry.isEmpty()) {
ItemStack value = entry.getValue();
- matrices.pushPose();
- matrices.translate(bounds.getCenterX(), bounds.getCenterY(), entry.getZ());
- matrices.mulPoseMatrix(new Matrix4f().scaling(1.0F, -1.0F, 1.0F));
- matrices.scale(bounds.getWidth(), bounds.getHeight(), (bounds.getWidth() + bounds.getHeight()) / 2.0F);
+ graphics.pose().pushPose();
+ graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0);
+ graphics.pose().mulPoseMatrix(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();
- Minecraft.getInstance().getItemRenderer().render(value, ItemDisplayContext.GUI, false, matrices, immediate,
+ Minecraft.getInstance().getItemRenderer().render(value, ItemDisplayContext.GUI, false, graphics.pose(), immediate,
ITEM_LIGHT, OverlayTexture.NO_OVERLAY, model);
immediate.endBatch();
- matrices.popPose();
+ graphics.pose().popPose();
}
PoseStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.pushPose();
- modelViewStack.mulPoseMatrix(matrices.last().pose());
+ modelViewStack.mulPoseMatrix(graphics.pose().last().pose());
modelViewStack.translate(bounds.x, bounds.y, 0);
modelViewStack.scale(bounds.width / 16f, (bounds.getWidth() + bounds.getHeight()) / 2f / 16f, 1.0F);
RenderSystem.applyModelViewMatrix();
- renderOverlay(new PoseStack(), entry, bounds);
+ renderOverlay(new GuiGraphics(Minecraft.getInstance(), graphics.bufferSource()), entry, bounds);
modelViewStack.popPose();
endGL(entry, model);
RenderSystem.applyModelViewMatrix();
@@ -287,7 +287,7 @@ public class ItemEntryDefinition implements EntryDefinition<ItemStack>, EntrySer
}
@Override
- public void startBatch(EntryStack<ItemStack> entry, BakedModel model, PoseStack matrices, float delta) {
+ public void startBatch(EntryStack<ItemStack> entry, BakedModel model, GuiGraphics graphics, float delta) {
setupGL(entry, model);
PoseStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.pushPose();
@@ -306,46 +306,46 @@ public class ItemEntryDefinition implements EntryDefinition<ItemStack>, EntrySer
}
@Override
- public void renderBase(EntryStack<ItemStack> entry, BakedModel model, PoseStack matrices, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ public void renderBase(EntryStack<ItemStack> entry, BakedModel model, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {
if (!entry.isEmpty()) {
ItemStack value = entry.getValue();
- matrices.pushPose();
- matrices.translate(bounds.getCenterX() / SCALE, bounds.getCenterY() / -SCALE, entry.getZ());
- matrices.scale(bounds.getWidth() / SCALE, (bounds.getWidth() + bounds.getHeight()) / 2f / SCALE, 1.0F);
- Minecraft.getInstance().getItemRenderer().render(value, ItemDisplayContext.GUI, false, matrices, immediate,
+ graphics.pose().pushPose();
+ graphics.pose().translate(bounds.getCenterX() / SCALE, bounds.getCenterY() / -SCALE, 0);
+ graphics.pose().scale(bounds.getWidth() / SCALE, (bounds.getWidth() + bounds.getHeight()) / 2f / SCALE, 1.0F);
+ Minecraft.getInstance().getItemRenderer().render(value, ItemDisplayContext.GUI, false, graphics.pose(), immediate,
ITEM_LIGHT, OverlayTexture.NO_OVERLAY, model);
- matrices.popPose();
+ graphics.pose().popPose();
}
}
@Override
- public void afterBase(EntryStack<ItemStack> entry, BakedModel model, PoseStack matrices, float delta) {
+ public void afterBase(EntryStack<ItemStack> entry, BakedModel model, GuiGraphics graphics, float delta) {
endGL(entry, model);
RenderSystem.getModelViewStack().popPose();
RenderSystem.applyModelViewMatrix();
}
@Override
- public void renderOverlay(EntryStack<ItemStack> entry, BakedModel model, PoseStack matrices, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ public void renderOverlay(EntryStack<ItemStack> entry, BakedModel model, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {
PoseStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.pushPose();
- modelViewStack.mulPoseMatrix(matrices.last().pose());
+ modelViewStack.mulPoseMatrix(graphics.pose().last().pose());
modelViewStack.translate(bounds.x, bounds.y, 0);
modelViewStack.scale(bounds.width / 16f, (bounds.getWidth() + bounds.getHeight()) / 2f / 16f, 1.0F);
RenderSystem.applyModelViewMatrix();
- renderOverlay(new PoseStack(), entry, bounds);
+ renderOverlay(new GuiGraphics(Minecraft.getInstance(), graphics.bufferSource()), entry, bounds);
modelViewStack.popPose();
RenderSystem.applyModelViewMatrix();
}
- public void renderOverlay(PoseStack matrices, EntryStack<ItemStack> entry, Rectangle bounds) {
+ public void renderOverlay(GuiGraphics graphics, EntryStack<ItemStack> entry, Rectangle bounds) {
if (!entry.isEmpty()) {
- Minecraft.getInstance().getItemRenderer().renderGuiItemDecorations(matrices, Minecraft.getInstance().font, entry.getValue(), 0, 0, null);
+ graphics.renderItemDecorations(Minecraft.getInstance().font, entry.getValue(), 0, 0, null);
}
}
@Override
- public void endBatch(EntryStack<ItemStack> entry, BakedModel model, PoseStack matrices, float delta) {
+ public void endBatch(EntryStack<ItemStack> entry, BakedModel model, GuiGraphics graphics, float delta) {
}
public void endGL(EntryStack<ItemStack> entry, BakedModel model) {
diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java
index 7783dd66c..db1ef180a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java
+++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java
@@ -23,8 +23,6 @@
package me.shedaniel.rei.plugin.client.runtime;
-import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.Lifecycle;
import dev.architectury.platform.Platform;
@@ -34,7 +32,6 @@ import me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.api.client.favorites.FavoriteEntry;
import me.shedaniel.rei.api.client.favorites.FavoriteEntryType;
-import me.shedaniel.rei.api.client.gui.AbstractRenderer;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponentProviderWidget;
import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponentVisitorWidget;
@@ -68,6 +65,7 @@ import me.shedaniel.rei.impl.common.util.HashedEntryStackWrapper;
import me.shedaniel.rei.plugin.autocrafting.DefaultCategoryHandler;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
@@ -99,13 +97,12 @@ public class DefaultClientRuntimePlugin implements REIClientPlugin {
@Override
public void registerEntries(EntryRegistry registry) {
if (ClientHelperImpl.getInstance().isAprilFools.get()) {
- registry.addEntry(ClientEntryStacks.of(new AbstractRenderer() {
+ registry.addEntry(ClientEntryStacks.of(new Renderer() {
private ResourceLocation id = new ResourceLocation("roughlyenoughitems", "textures/gui/kirb.png");
@Override
- public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
- RenderSystem.setShaderTexture(0, id);
- innerBlit(matrices.last().pose(), bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), getZ(), 0, 1, 0, 1);
+ public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ graphics.innerBlit(id, bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), 0, 0, 1, 0, 1);
}
@Override