Skip to content

Commit

Permalink
Move ASM transformer to mixin potion render fix (#101)
Browse files Browse the repository at this point in the history
* Add a debug message in the chat when toggling vanilla debug options

* update dependencies and use GTNH lib to print chat message

* update dependencies to get NEI fix that causes mixins to crash

* move the potion rendering over NEI fix from ASM to mixins

* changed the mixin to center the inventory

* applys spotless

* use the same name for potion offset

* Fix the vanilla bug that doesn't render the potion effects that you get while your inventory is opened
  • Loading branch information
Alexdoru authored Sep 6, 2022
1 parent eb6c039 commit 921ae36
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 184 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dependencies {
compile("com.github.GTNewHorizons:NotEnoughItems:2.3.1-GTNH:dev")
compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.41.18:dev")
compile("com.github.GTNewHorizons:StructureLib:1.0.15:dev")
compile("com.github.GTNewHorizons:GTNHLib:0.0.3:dev")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public enum AsmTransformers {
"Speed up Progress Bar by speeding up stripSpecialCharacters",
() -> Hodgepodge.config.speedupProgressBar,
Collections.singletonList("com.mitchej123.hodgepodge.asm.SpeedupProgressBarTransformer")),
FIX_POTION_EFFECT_RENDERING(
"Fix vanilla potion effects rendering above the NEI tooltips in the inventory",
() -> Hodgepodge.config.fixPotionEffectRender,
Collections.singletonList("com.mitchej123.hodgepodge.asm.InventoryEffectRendererTransformer")),
FIX_TINKER_POTION_EFFECT_OFFSET(
"Prevents the inventory from shifting when the player has active potion effects",
() -> Hodgepodge.config.fixPotionRenderOffset,
Expand Down

This file was deleted.

9 changes: 7 additions & 2 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ public enum Mixins {
FENCE_CONNECTIONS_FIX(
"minecraft.MixinBlockFence", () -> Hodgepodge.config.fixFenceConnections, TargetedMod.VANILLA),
FIX_INVENTORY_OFFSET_WITH_POTIONS(
"minecraft.MixinInventoryEffectRenderer",
"minecraft.MixinInventoryEffectRenderer_PotionOffset",
Side.CLIENT,
() -> Hodgepodge.config.fixPotionRenderOffset,
TargetedMod.VANILLA),
FIX_POTION_EFFECT_RENDERING(
"minecraft.MixinInventoryEffectRenderer_PotionEffectRendering",
Side.CLIENT,
() -> Hodgepodge.config.fixPotionEffectRender,
TargetedMod.VANILLA),
CHUNK_COORDINATES_HASHCODE(
"minecraft.MixinChunkCoordinates",
() -> Hodgepodge.config.speedupChunkCoordinatesHashCode,
Expand Down Expand Up @@ -293,6 +298,6 @@ public boolean shouldLoad(List<TargetedMod> loadedMods) {
enum Side {
BOTH,
CLIENT,
SERVER;
SERVER
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.mitchej123.hodgepodge.mixins.minecraft;

import codechicken.nei.NEIClientConfig;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.inventory.Container;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(InventoryEffectRenderer.class)
public abstract class MixinInventoryEffectRenderer_PotionEffectRendering extends GuiContainer {

@Shadow
private void func_147044_g() {}

/**
* @author Alexdoru
* @reason Fix the bug that renders the potion effects above the tooltips from items in NEI
* Fix the vanilla bug that doesn't render the potion effects that you get while your inventory
* is opened
*/
@Overwrite
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
boolean bookmarkPanelHidden = NEIClientConfig.isHidden();
if (bookmarkPanelHidden) {
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
if (!this.mc.thePlayer.getActivePotionEffects().isEmpty()) {
this.func_147044_g();
}
if (bookmarkPanelHidden) {
return;
}
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}

/*Forced to have constructor matching super*/
public MixinInventoryEffectRenderer_PotionEffectRendering(Container p_i1089_1_) {
super(p_i1089_1_);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.mitchej123.hodgepodge.mixins.minecraft;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.inventory.Container;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(InventoryEffectRenderer.class)
public abstract class MixinInventoryEffectRenderer_PotionOffset extends GuiContainer {

@Redirect(
method = "initGui",
at =
@At(
value = "FIELD",
target = "Lnet/minecraft/client/renderer/InventoryEffectRenderer;guiLeft:I",
opcode = Opcodes.PUTFIELD))
public void hodgepodge$fixPotionOffset(InventoryEffectRenderer instance, int value) {
this.guiLeft = (this.width - this.xSize) / 2;
}

/*Forced to have constructor matching super*/
public MixinInventoryEffectRenderer_PotionOffset(Container p_i1072_1_) {
super(p_i1072_1_);
}
}

0 comments on commit 921ae36

Please sign in to comment.