Skip to content

Commit 08a6d38

Browse files
authored
Merge pull request RobertSkalko#198 from TUsama/spellbar
don't render spell hot bar when player doesn't equip any spells
2 parents d6d7a5d + 91a51ec commit 08a6d38

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/main/java/com/robertx22/mine_and_slash/config/forge/ClientConfigs.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class ClientConfigs {
5454
DONT_CULL_PARTICLES_UNDER = b.defineInRange("DONT_CULL_PARTICLES_UNDER", 50D, 0D, 5000D);
5555

5656
HOTBAR_SWAPPING = b.comment("When OFF: 8 bars, 8 keybinds. When ON: 4 bars, 5 keybinds(4 for each bar, 1 for hotbar swap button)").define("HOTBAR_SWAPPING", false);
57+
HIDE_SPELL_HOTBAR_WHEN_NO_SPELL = b.define("hide_spell_hotbar_when_no_spell", true);
5758

5859
GUI_POSITION = b.defineEnum("GUI_POSITION", GuiPosition.TOP_LEFT);
5960
ITEM_RARITY_BACKGROUND_TYPE = b.defineEnum("ITEM_RARITY_BACKGROUND_TYPE", GlintType.FULL);
@@ -79,13 +80,15 @@ public class ClientConfigs {
7980
OVERLAY_CONFIGS.put(type, b.defineEnum(type.name() + "_" + "CONFIG", type.getDefaultConfig()));
8081
}
8182
}
83+
b.pop();
8284
b.comment("Buttons").push("buttons");
8385
ENABLE_QUICK_LOOT_BUTTON = b.define("enable_quick_loot_button", true);
8486
QUICK_LOOT_BUTTON_X_OFFSET = b.define("quick_loot_button_x_offset", 0);
8587
QUICK_LOOT_BUTTON_Y_OFFSET = b.define("quick_loot_button_y_offset", 0);
8688

8789
b.pop();
8890

91+
8992
}
9093

9194

@@ -100,6 +103,7 @@ public class ClientConfigs {
100103
public ForgeConfigSpec.BooleanValue MODIFY_TOOLTIP_LENGTH;
101104
public ForgeConfigSpec.BooleanValue IN_DEPTH_TOOLTIPS_BY_DEFAULT;
102105
public ForgeConfigSpec.BooleanValue HOTBAR_SWAPPING;
106+
public ForgeConfigSpec.BooleanValue HIDE_SPELL_HOTBAR_WHEN_NO_SPELL;
103107
public ForgeConfigSpec.BooleanValue USE_SPELL_ANIMATIONS;
104108
public ForgeConfigSpec.EnumValue<GuiBarRenderOption> RENDER_FILLED_GUI_BARS;
105109

src/main/java/com/robertx22/mine_and_slash/gui/overlays/spell_hotbar/SpellHotbarOverlay.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
import net.minecraft.client.gui.GuiGraphics;
1414
import net.minecraft.resources.ResourceLocation;
1515

16+
import java.util.ArrayList;
17+
import java.util.List;
18+
19+
1620
public class SpellHotbarOverlay {
1721

1822

@@ -51,20 +55,23 @@ public void onHudRender(GuiGraphics gui, OverlayConfig config, OverlayType type)
5155
int x = config.getPos().x;
5256
int y = config.getPos().y;
5357

54-
55-
renderHotbarBackground(type, type.getSize(), gui, x, y);
56-
5758
int spells = 8;
58-
59+
List<SpellOnHotbarRender> list = new ArrayList<>();
5960

6061
for (int i = 0; i < spells; i++) {
61-
6262
int place = i;
6363
int xp = x + 3;
6464
int yp = y + 3;
65-
66-
var spellRen = new SpellOnHotbarRender(type == OverlayType.SPELL_HOTBAR_HORIZONTAL, place, gui, xp, yp);
67-
spellRen.render();
65+
list.add(new SpellOnHotbarRender(type == OverlayType.SPELL_HOTBAR_HORIZONTAL, place, gui, xp, yp)) ;
66+
}
67+
if (ClientConfigs.getConfig().HIDE_SPELL_HOTBAR_WHEN_NO_SPELL.get()){
68+
if (list.stream().anyMatch(spell -> spell.spell != null)){
69+
renderHotbarBackground(type, type.getSize(), gui, x, y);
70+
list.forEach(SpellOnHotbarRender::render);
71+
}
72+
} else {
73+
renderHotbarBackground(type, type.getSize(), gui, x, y);
74+
list.forEach(SpellOnHotbarRender::render);
6875
}
6976

7077
RenderSystem.disableBlend(); // enables transparency

0 commit comments

Comments
 (0)