Skip to content

Commit 8a4f6d5

Browse files
committed
disable option
1 parent bc94f1d commit 8a4f6d5

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/main/java/dev/dfonline/codeclient/config/Config.java

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ private void save() {
104104
object.addProperty("UseSelectionColor",UseSelectionColor);
105105
object.addProperty("Line4Color",Line4Color);
106106
object.addProperty("SignPeeker",SignPeeker);
107+
object.addProperty("CustomCodeChest",CustomCodeChest.name());
107108
FileManager.writeConfig(object.toString());
108109
} catch (Exception e) {
109110
CodeClient.LOGGER.info("Couldn't save config: " + e);
@@ -403,6 +404,7 @@ public YetAnotherConfigLib getLibConfig() {
403404
opt -> CustomCodeChest = opt
404405
)
405406
.controller(nodeOption -> () -> new EnumController<>(nodeOption, CustomChestMenuType.class))
407+
.available(false)
406408
.build())
407409
.option(Option.createBuilder(boolean.class)
408410
.name(Text.literal("Place on Air"))

src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestMenu.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
import org.lwjgl.glfw.GLFW;
2323

2424
import java.util.ArrayList;
25+
import java.util.HashMap;
2526
import java.util.List;
2627

2728
public class CustomChestMenu extends HandledScreen<CustomChestHandler> implements ScreenHandlerProvider<CustomChestHandler> {
2829

2930
private final CustomChestNumbers Size;
3031
private double scroll = 0;
31-
private final ArrayList<Widget> widgets = new ArrayList<>();
32+
private final HashMap<Integer,Widget> widgets = new HashMap<>();
3233
private final ArrayList<VarItem> varItems = new ArrayList<>();
3334
private boolean update = true;
3435

@@ -70,7 +71,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
7071
super.render(context, mouseX, mouseY, delta);
7172
context.getMatrices().push();
7273
context.getMatrices().translate(this.x, this.y, 0);
73-
for (Widget widget : widgets) {
74+
for (Widget widget : widgets.values()) {
7475
if (widget instanceof Drawable drawable) {
7576
drawable.render(context, mouseX, mouseY, delta);
7677
}
@@ -132,12 +133,12 @@ private void update(int previousScroll) {
132133
// widget.setText(named.getName());
133134
// widget.setFocused(Objects.equals(i,focused));
134135
var widget = new CustomChestField<>(textRenderer, x, y, Size.WIDGET_WIDTH, 18, Text.of(varItem.id), varItem);
135-
widgets.add(widget);
136+
widgets.put(i,widget);
136137
varItems.add(varItem);
137138
continue;
138139
}
139140

140-
widgets.add(new TextWidget(x + 3,y,Size.WIDGET_WIDTH,16,stack.getName(),textRenderer).alignLeft());
141+
widgets.put(i,new TextWidget(x + 3,y,Size.WIDGET_WIDTH,16,stack.getName(),textRenderer).alignLeft());
141142
}
142143
}
143144

@@ -161,7 +162,7 @@ public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmou
161162
@Override
162163
public boolean mouseClicked(double mouseX, double mouseY, int button) {
163164
List<Slot> subList = this.getScreenHandler().slots.subList((int) scroll, Math.min((int) scroll + Size.SLOTS,27));
164-
for (Widget widget : widgets) {
165+
for (Widget widget : widgets.values()) {
165166
if (widget instanceof ClickableWidget clickable) {
166167
clickable.setFocused(clickable.isMouseOver(mouseX - this.x, mouseY - this.y));
167168
clickable.mouseClicked(mouseX - this.x,mouseY - this.y,button);

0 commit comments

Comments
 (0)