Skip to content

Commit

Permalink
Small mixin fix (#17)
Browse files Browse the repository at this point in the history
* activate mixin debug in dev env

* make GuiScreenAccessor.getItemRender() static since the underlying field is
  • Loading branch information
Alexdoru authored Oct 4, 2024
1 parent a7de84e commit 29f75f5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ usesMixins = true
separateMixinSourceSet =

# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
usesMixinDebug = true

# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public static void drawItem(ItemStack item, int x, int y, float width, float hei
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(x, y, 0);
GL11.glScalef(width / 16f, height / 16f, 1);
RenderItem renderItem = ((GuiScreenAccessor) Minecraft.getMinecraft().currentScreen).getItemRender();
RenderItem renderItem = GuiScreenAccessor.getItemRender();
renderItem.zLevel = 200;
renderItem.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), item, 0, 0);
GuiDraw.afterRenderItemAndEffectIntoGUI(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public interface GuiScreenAccessor {
void setLastMouseEvent(long event);

@Accessor
RenderItem getItemRender();
static RenderItem getItemRender() {
throw new UnsupportedOperationException("Mixin failed to inject!");
}

@Accessor("fontRendererObj")
FontRenderer getFontRenderer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,16 @@ private static boolean shouldRenderNEITooltip(ModularScreen muiScreen) {
private static void drawItemStack(GuiContainer mcScreen, ItemStack stack, int x, int y, String altText) {
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
((GuiAccessor) mcScreen).setZLevel(200f);
((GuiScreenAccessor) mcScreen).getItemRender().zLevel = 200.0F;
GuiScreenAccessor.getItemRender().zLevel = 200.0F;
FontRenderer font = stack.getItem().getFontRenderer(stack);
if (font == null) font = ((GuiScreenAccessor) mcScreen).getFontRenderer();
GL11.glEnable(GL11.GL_DEPTH_TEST);
((GuiScreenAccessor) mcScreen).getItemRender().renderItemAndEffectIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), stack, x, y);
GuiScreenAccessor.getItemRender().renderItemAndEffectIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), stack, x, y);
GuiDraw.afterRenderItemAndEffectIntoGUI(stack);
((GuiScreenAccessor) mcScreen).getItemRender().renderItemOverlayIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), stack, x, y - (((GuiContainerAccessor) mcScreen).getDraggedStack() == null ? 0 : 8), altText);
GuiScreenAccessor.getItemRender().renderItemOverlayIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), stack, x, y - (((GuiContainerAccessor) mcScreen).getDraggedStack() == null ? 0 : 8), altText);
GL11.glDisable(GL11.GL_DEPTH_TEST);
((GuiAccessor) mcScreen).setZLevel(0f);
((GuiScreenAccessor) mcScreen).getItemRender().zLevel = 0.0F;
GuiScreenAccessor.getItemRender().zLevel = 0.0F;
}

private static void drawVanillaElements(GuiScreen mcScreen, int mouseX, int mouseY, float partialTicks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void drawSlot(ModularSlot slotIn) {
if (!(guiScreen instanceof GuiContainer))
throw new IllegalStateException("The gui must be an instance of GuiContainer if it contains slots!");
GuiContainerAccessor acc = (GuiContainerAccessor) guiScreen;
RenderItem renderItem = ((GuiScreenAccessor) guiScreen).getItemRender();
RenderItem renderItem = GuiScreenAccessor.getItemRender();
ItemStack itemstack = slotIn.getStack();
boolean flag = false;
boolean flag1 = slotIn == acc.getClickedSlot() && acc.getDraggedStack() != null && !acc.getIsRightMouseClick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void drawSlot(ModularSlotLong slotIn) {
if (!(guiScreen instanceof GuiContainer))
throw new IllegalStateException("The gui must be an instance of GuiContainer if it contains slots!");
GuiContainerAccessor acc = (GuiContainerAccessor) guiScreen;
RenderItem renderItem = ((GuiScreenAccessor) guiScreen).getItemRender();
RenderItem renderItem = GuiScreenAccessor.getItemRender();
IItemStackLong itemstack = slotIn.getStackLong();
boolean flag = false;
boolean flag1 = slotIn == acc.getClickedSlot() && acc.getDraggedStack() != null && !acc.getIsRightMouseClick();
Expand Down

0 comments on commit 29f75f5

Please sign in to comment.