Skip to content

Commit

Permalink
Move mana pool recipe render position if also holding wand (#4522)
Browse files Browse the repository at this point in the history
The recipe overlay is rendered above the crosshair instead of below to
prevent overlapping with the wand's mana pool overlay. (fixes #4433)
  • Loading branch information
TheRealWormbo authored Dec 30, 2023
1 parent 128ee35 commit 6feb108
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Xplat/src/main/java/vazkii/botania/client/gui/HUDHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,19 @@ public static void onDrawScreenPost(GuiGraphics gui, float partialTicks) {
BlockEntity tile = mc.level.getBlockEntity(bpos);

if (PlayerHelper.hasAnyHeldItem(mc.player)) {
boolean alternateRecipeHudPosition = false;
if (PlayerHelper.hasHeldItemClass(mc.player, WandOfTheForestItem.class)) {
tryOptifineWarning();
var hud = ClientXplatAbstractions.INSTANCE.findWandHud(mc.level, bpos, state, tile);
if (hud != null) {
alternateRecipeHudPosition = true;
profiler.push("wandItem");
hud.renderHUD(gui, mc);
profiler.pop();
}
}
if (tile instanceof ManaPoolBlockEntity pool && !mc.player.getMainHandItem().isEmpty()) {
renderPoolRecipeHUD(gui, pool, mc.player.getMainHandItem());
renderPoolRecipeHUD(gui, pool, mc.player.getMainHandItem(), alternateRecipeHudPosition);
}
}
if (!PlayerHelper.hasHeldItem(mc.player, BotaniaItems.lexicon)) {
Expand Down Expand Up @@ -261,15 +263,15 @@ private static void renderManaInvBar(GuiGraphics gui, int totalMana, int totalMa
RenderSystem.setShaderColor(1, 1, 1, 1);
}

private static void renderPoolRecipeHUD(GuiGraphics gui, ManaPoolBlockEntity tile, ItemStack stack) {
private static void renderPoolRecipeHUD(GuiGraphics gui, ManaPoolBlockEntity tile, ItemStack stack, boolean alternateRecipeHudPosition) {
Minecraft mc = Minecraft.getInstance();
ProfilerFiller profiler = mc.getProfiler();

profiler.push("poolRecipe");
ManaInfusionRecipe recipe = tile.getMatchingRecipe(stack, tile.getLevel().getBlockState(tile.getBlockPos().below()));
if (recipe != null) {
int x = mc.getWindow().getGuiScaledWidth() / 2 - 11;
int y = mc.getWindow().getGuiScaledHeight() / 2 + 10;
int y = mc.getWindow().getGuiScaledHeight() / 2 + (alternateRecipeHudPosition ? -25 : 10);

int u = tile.getCurrentMana() >= recipe.getManaToConsume() ? 0 : 22;
int v = mc.player.getName().getString().equals("haighyorkie") && mc.player.isShiftKeyDown() ? 23 : 8;
Expand Down

0 comments on commit 6feb108

Please sign in to comment.