Skip to content

Commit 17cd494

Browse files
committed
add config
1 parent d94adc7 commit 17cd494

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/java/com/robertx22/mine_and_slash/capability/player/container/BackpackQuickLootButton.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.robertx22.mine_and_slash.capability.player.container;
22

33
import com.robertx22.library_of_exile.main.Packets;
4+
import com.robertx22.mine_and_slash.config.forge.ClientConfigs;
45
import com.robertx22.mine_and_slash.mmorpg.SlashRef;
56
import com.robertx22.mine_and_slash.uncommon.localization.Gui;
67
import com.robertx22.mine_and_slash.vanilla_mc.packets.backpack.BackPackLootMenuPacket;
@@ -17,14 +18,14 @@
1718
public class BackpackQuickLootButton extends ImageButton {
1819
static ResourceLocation TEXTURE = SlashRef.id("textures/gui/backpack_button.png");
1920
public BackpackQuickLootButton(int pX, int pY, ContainerScreen screen) {
20-
super(pX, pY, 14, 14, 0, 0, 16, TEXTURE, 16, 32, x -> Packets.sendToServer(new BackPackLootMenuPacket()), Gui.MASTER_BACKPACK_LOOT_BUTTON.locName());
21+
super(pX + ClientConfigs.getConfig().QUICK_LOOT_BUTTON_X_OFFSET.get(), pY + ClientConfigs.getConfig().QUICK_LOOT_BUTTON_Y_OFFSET.get(), 14, 14, 0, 0, 16, TEXTURE, 16, 32, x -> Packets.sendToServer(new BackPackLootMenuPacket()), Gui.MASTER_BACKPACK_LOOT_BUTTON.locName());
2122
this.setTooltip(Tooltip.create(Gui.MASTER_BACKPACK_LOOT_BUTTON.locName()));
2223
}
2324

2425

2526
public static void addLootButton(ScreenEvent.Init event){
2627
if (!(event instanceof ScreenEvent.Init.Post)) return;
27-
if (Minecraft.getInstance().screen instanceof ContainerScreen containerScreen){
28+
if (Minecraft.getInstance().screen instanceof ContainerScreen containerScreen && ClientConfigs.getConfig().ENABLE_QUICK_LOOT_BUTTON.get()){
2829
event.addListener(new BackpackQuickLootButton(containerScreen.getGuiLeft() + containerScreen.getXSize(), containerScreen.getGuiTop(), containerScreen));
2930
}
3031
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ public class ClientConfigs {
7979
OVERLAY_CONFIGS.put(type, b.defineEnum(type.name() + "_" + "CONFIG", type.getDefaultConfig()));
8080
}
8181
}
82-
82+
b.comment("Buttons").push("buttons");
83+
ENABLE_QUICK_LOOT_BUTTON = b.define("enable_quick_loot_button", true);
84+
QUICK_LOOT_BUTTON_X_OFFSET = b.define("quick_loot_button_x_offset", 0);
85+
QUICK_LOOT_BUTTON_Y_OFFSET = b.define("quick_loot_button_y_offset", 0);
8386

8487
b.pop();
8588

@@ -116,6 +119,10 @@ public class ClientConfigs {
116119
public ForgeConfigSpec.IntValue REMOVE_EMPTY_TOOLTIP_LINES_IF_MORE_THAN_X_LINES;
117120
public ForgeConfigSpec.IntValue SHOW_DECIMALS_ON_NUMBER_SMALLER_THAN;
118121

122+
public ForgeConfigSpec.BooleanValue ENABLE_QUICK_LOOT_BUTTON;
123+
public ForgeConfigSpec.ConfigValue<Integer> QUICK_LOOT_BUTTON_X_OFFSET;
124+
public ForgeConfigSpec.ConfigValue<Integer> QUICK_LOOT_BUTTON_Y_OFFSET;
125+
119126

120127
public OverlayConfig getOverlayConfig(OverlayType type) {
121128
var preset = OVERLAY_CONFIGS.get(type).get();

0 commit comments

Comments
 (0)