Skip to content

Commit

Permalink
Reposition the selected item text to be a bit further above the tempe…
Browse files Browse the repository at this point in the history
…rature orb
  • Loading branch information
Adubbz committed Jan 3, 2024
1 parent b6d5aef commit 98440b7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions common/src/main/java/toughasnails/mixin/client/MixinGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@ public void onRenderHeart(GuiGraphics gui, Gui.HeartType heartType, int x, int y
TemperatureHooksClient.heartBlit(gui, heartType, x, y, isHardcore, isBlinking, isHalf);
ci.cancel();
}

@Inject(method="renderSelectedItemName", at=@At(value="HEAD"))
public void onRenderSelectedItemNameBegin(GuiGraphics guiGraphics, CallbackInfo ci)
{
var pose = guiGraphics.pose();
pose.pushPose();
TemperatureHooksClient.adjustSelectedItemText(guiGraphics);
}

@Inject(method="renderSelectedItemName", at=@At(value="TAIL"))
public void onRenderSelectedItemNameEnd(GuiGraphics guiGraphics, CallbackInfo ci)
{
guiGraphics.pose().popPose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.resources.ResourceLocation;
import toughasnails.api.temperature.TemperatureHelper;
import toughasnails.init.ModConfig;

public class TemperatureHooksClient
{
Expand Down Expand Up @@ -38,6 +39,17 @@ public static void heartBlit(GuiGraphics gui, Gui.HeartType heartType, int x, in
}
}

public static void adjustSelectedItemText(GuiGraphics guiGraphics)
{
var pose = guiGraphics.pose();

// If temperature is enabled, move the selected item text up by 2 pixels
if (ModConfig.temperature.enableTemperature)
{
pose.translate(0F, -2F, 0F);
}
}

private static ResourceLocation getOverheatedHeartSprite(boolean isHardcore, boolean isHalf, boolean isBlinking)
{
if (!isHardcore)
Expand Down

0 comments on commit 98440b7

Please sign in to comment.