• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 15509500774

07 Jun 2025 04:05PM UTC coverage: 44.896% (-0.007%) from 44.903%
15509500774

push

github

rubensworks
Bump mod version

2576 of 8518 branches covered (30.24%)

Branch coverage included in aggregate %.

11767 of 23429 relevant lines covered (50.22%)

2.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/cyclops/integrateddynamics/client/gui/container/ContainerScreenLogicProgrammerBase.java
1
package org.cyclops.integrateddynamics.client.gui.container;
2

3
import com.google.common.collect.Lists;
4
import com.mojang.blaze3d.platform.InputConstants;
5
import com.mojang.blaze3d.systems.RenderSystem;
6
import net.minecraft.client.Minecraft;
7
import net.minecraft.client.gui.Font;
8
import net.minecraft.client.gui.GuiGraphics;
9
import net.minecraft.client.renderer.texture.TextureManager;
10
import net.minecraft.network.chat.Component;
11
import net.minecraft.network.chat.MutableComponent;
12
import net.minecraft.resources.ResourceLocation;
13
import net.minecraft.world.entity.player.Inventory;
14
import net.minecraft.world.item.ItemStack;
15
import org.apache.commons.lang3.tuple.Triple;
16
import org.cyclops.cyclopscore.client.gui.component.button.ButtonText;
17
import org.cyclops.cyclopscore.client.gui.component.input.WidgetTextFieldExtended;
18
import org.cyclops.cyclopscore.client.gui.container.ContainerScreenScrolling;
19
import org.cyclops.cyclopscore.client.gui.image.Images;
20
import org.cyclops.cyclopscore.helper.Helpers;
21
import org.cyclops.cyclopscore.helper.MinecraftHelpers;
22
import org.cyclops.cyclopscore.helper.RenderHelpers;
23
import org.cyclops.integrateddynamics.IntegratedDynamics;
24
import org.cyclops.integrateddynamics.Reference;
25
import org.cyclops.integrateddynamics.RegistryEntries;
26
import org.cyclops.integrateddynamics.api.client.gui.subgui.IGuiInputElement;
27
import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElement;
28
import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElementType;
29
import org.cyclops.integrateddynamics.core.client.gui.subgui.SubGuiHolder;
30
import org.cyclops.integrateddynamics.core.evaluate.variable.gui.GuiElementValueTypeString;
31
import org.cyclops.integrateddynamics.core.helper.L10NValues;
32
import org.cyclops.integrateddynamics.core.logicprogrammer.LogicProgrammerElementTypes;
33
import org.cyclops.integrateddynamics.core.logicprogrammer.RenderPattern;
34
import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase;
35
import org.cyclops.integrateddynamics.network.packet.LogicProgrammerActivateElementPacket;
36
import org.cyclops.integrateddynamics.network.packet.LogicProgrammerLabelPacket;
37
import org.cyclops.integrateddynamics.proxy.ClientProxy;
38
import org.lwjgl.glfw.GLFW;
39

40
import javax.annotation.Nullable;
41
import java.awt.*;
42
import java.util.List;
43

44
/**
45
 * Base gui for the logic programmer.
46
 * @author rubensworks
47
 */
48
public class ContainerScreenLogicProgrammerBase<C extends ContainerLogicProgrammerBase> extends ContainerScreenScrolling<C> {
49

50
    public static final int BOX_HEIGHT = 18;
51
    private static final Rectangle ITEM_POSITION = new Rectangle(19, 18, 56, BOX_HEIGHT - 1);
×
52

53
    protected final SubGuiHolder subGuiHolder = new SubGuiHolder();
×
54
    private final boolean hasLabeller;
55
    protected RenderPattern operatorConfigPattern = null;
×
56
    protected SubGuiOperatorInfo operatorInfoPattern = null;
×
57
    protected boolean firstInit = true;
×
58
    protected int relativeStep = -1;
×
59
    protected boolean swallowNextCharacter = false;
×
60
    private ButtonText resetButton;
61

62
    public ContainerScreenLogicProgrammerBase(C container, Inventory playerInventory, Component title) {
63
        super(container, playerInventory, title);
×
64
        container.setGui(this);
×
65
        this.titleLabelX = 87;
×
66

67
        this.hasLabeller = playerInventory.contains(new ItemStack(RegistryEntries.ITEM_LABELLER));
×
68
    }
×
69

70
    @Override
71
    protected Rectangle getScrollRegion() {
72
        return new Rectangle(this.leftPos + 19, this.topPos + 18, 57, 178);
×
73
    }
74

75
    @Override
76
    public void init() {
77
        super.init();
×
78

79
        // Button to deselect the active LP element
80
        addRenderableWidget(this.resetButton = new ButtonText(this.leftPos + 87,  this.topPos + 4,
×
81
                Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_RESET),
×
82
                Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_RESET), button -> {
×
83
            if (container.getActiveElement() != null) {
×
84
                container.returnWriteItemToPlayer();
×
85
                handleElementActivation(container.getActiveElement(), true);
×
86
            }
87
        }));
×
88
        this.resetButton.setHeight(12);
×
89
        resetButton.visible = false;
×
90

91
        subGuiHolder.init(this.leftPos, this.topPos);
×
92
        if (firstInit) {
×
93
            setSearchFieldFocussed(true);
×
94
            firstInit = false;
×
95
        }
96
    }
×
97

98
    @Override
99
    public void containerTick() {
100
        super.containerTick();
×
101
        subGuiHolder.tick();
×
102
    }
×
103

104
    protected int getScrollX() {
105
        return 5;
×
106
    }
107

108
    protected int getScrollY() {
109
        return 18;
×
110
    }
111

112
    protected int getScrollHeight() {
113
        return 178;
×
114
    }
115

116
    @Override
117
    protected int getBaseXSize() {
118
        return 256;
×
119
    }
120

121
    @Override
122
    protected int getBaseYSize() {
123
        return 240;
×
124
    }
125

126
    @Override
127
    protected int getSearchX() {
128
        return 6;
×
129
    }
130

131
    protected int getSearchWidth() {
132
        return 70;
×
133
    }
134

135
    @Override
136
    protected ResourceLocation constructGuiTexture() {
137
        return ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "textures/gui/logic_programmer.png");
×
138
    }
139

140
    protected float colorSmoothener(float color, boolean hover) {
141
        return 1F - ((1F - color) / (hover ? 2F : 4F));
×
142
    }
143

144
    @Override
145
    protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
146
        super.renderBg(guiGraphics, partialTicks, mouseX, mouseY);
×
147
        subGuiHolder.renderBg(guiGraphics, this.leftPos, this.topPos, getMinecraft().getTextureManager(), font, partialTicks, mouseX, mouseY);
×
148

149
        // Draw container name
150
        font.drawInBatch(Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_FILTER),
×
151
                this.leftPos + offsetX + 5, this.topPos + offsetY + 208, Helpers.RGBToInt(80, 80, 80),
×
152
                false, guiGraphics.pose().last().pose(), guiGraphics.bufferSource(), Font.DisplayMode.NORMAL, 0, 15728880);
×
153

154
        // Draw operators
155
        ContainerLogicProgrammerBase container = (ContainerLogicProgrammerBase) getMenu();
×
156
        int boxHeight = BOX_HEIGHT;
×
157
        for(int i = 0; i < container.getPageSize(); i++) {
×
158
            if(container.isElementVisible(i)) {
×
159
                ILogicProgrammerElement element = container.getVisibleElement(i);
×
160

161
                Triple<Float, Float, Float> rgb = Helpers.intToRGB(element.getColor());
×
162
                boolean hover = LogicProgrammerElementTypes.areEqual(container.getActiveElement(), element)
×
163
                        || isPointInRegion(getElementPosition(container, i, false), new Point(mouseX, mouseY));
×
164
                RenderSystem.setShaderColor(colorSmoothener(rgb.getLeft(), hover), colorSmoothener(rgb.getMiddle(), hover),
×
165
                        colorSmoothener(rgb.getRight(), hover), 1);
×
166

167
                // Background
168
                guiGraphics.blit(texture, leftPos + offsetX + ITEM_POSITION.x,
×
169
                        topPos + offsetY + ITEM_POSITION.y + boxHeight * i, 19, 18, ITEM_POSITION.width, ITEM_POSITION.height);
170

171
                // Arrow
172
                if(hover) {
×
173
                    guiGraphics.blit(texture, leftPos + offsetX + ITEM_POSITION.x,
×
174
                            topPos + offsetY + ITEM_POSITION.y + boxHeight * i, 0, 240, 3, 16);
175
                }
176
                RenderSystem.setShaderColor(1, 1, 1, 1);
×
177

178
                // Operator info
179
                String aspectName = element.getSymbol();
×
180
                RenderHelpers.drawScaledCenteredString(guiGraphics.pose(), guiGraphics.bufferSource(), font, aspectName,
×
181
                        this.leftPos + offsetX + (hover ? 22 : 21),
×
182
                        this.topPos + offsetY + 26 + boxHeight * i,
183
                        53, Helpers.RGBToInt(40, 40, 40), false, Font.DisplayMode.NORMAL);
×
184
            }
185
        }
186

187
        // Draw arrow on write slot
188
        guiGraphics.blit(texture, leftPos + offsetX + ContainerLogicProgrammerBase.OUTPUT_X - 4,
×
189
                topPos + offsetY + ContainerLogicProgrammerBase.OUTPUT_Y - 4, subGuiHolder.isEmpty() ? 7 : 3, 240, 4, 4);
×
190
    }
×
191

192
    protected Rectangle getElementPosition(ContainerLogicProgrammerBase container, int i, boolean absolute) {
193
        return new Rectangle(ITEM_POSITION.x + offsetX + (absolute ? this.leftPos : 0),
×
194
                ITEM_POSITION.y + BOX_HEIGHT * i + offsetY + (absolute ? this.topPos : 0),
×
195
                ITEM_POSITION.width, ITEM_POSITION.height
196
        );
197
    }
198

199
    @Override
200
    protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
201
        // super.drawGuiContainerForegroundLayer(matrixStack, mouseX, mouseY);
202
        subGuiHolder.drawGuiContainerForegroundLayer(guiGraphics, this.leftPos, this.topPos, getMinecraft().getTextureManager(), font, mouseX, mouseY);
×
203

204
        // Draw usage information
205
        if (subGuiHolder.isEmpty()) {
×
206
            // Create
207
            Images.ARROW_LEFT.draw(guiGraphics, offsetX + 85, offsetY + 17);
×
208
            guiGraphics.drawString(font, Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_INFO_CREATE),
×
209
                    offsetX + 100, offsetY + 23, Helpers.RGBToInt(80, 80, 80), false);
×
210

211
            // Modify
212
            Images.ARROW_DOWN.draw(guiGraphics, offsetX + 230, offsetY + 90);
×
213
            MutableComponent modifyComponent = Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_INFO_MODIFY);
×
214
            guiGraphics.drawString(font, modifyComponent,
×
215
                    offsetX + 230 - font.width(modifyComponent), offsetY + 95, Helpers.RGBToInt(80, 80, 80), false);
×
216

217
            // Tooltip on write slot
218
            if (this.isHovering(ContainerLogicProgrammerBase.OUTPUT_X, ContainerLogicProgrammerBase.OUTPUT_Y,
×
219
                    ContainerScreenLogicProgrammerBase.BOX_HEIGHT, ContainerScreenLogicProgrammerBase.BOX_HEIGHT, mouseX, mouseY)
220
                    && Minecraft.getInstance().player.containerMenu.getCarried().isEmpty()
×
221
                    && !container.hasWriteItemInSlot()) {
×
222
                this.drawTooltip(Lists.newArrayList(Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_TOOLTIP_WRITESLOT_MODIFY)), guiGraphics.pose(), mouseX - this.leftPos, mouseY - this.topPos);
×
223
            }
224
        }
225

226
        // Draw operator tooltips
227
        ContainerLogicProgrammerBase container = getMenu();
×
228
        for(int i = 0; i < container.getPageSize(); i++) {
×
229
            if(container.isElementVisible(i)) {
×
230
                ILogicProgrammerElement element = container.getVisibleElement(i);
×
231
                if(isPointInRegion(getElementPosition(container, i, false), new Point(mouseX, mouseY))) {
×
232
                    List<Component> lines = Lists.newLinkedList();
×
233
                    element.loadTooltip(lines);
×
234
                    drawTooltip(lines, guiGraphics.pose(), mouseX - this.leftPos, mouseY - this.topPos);
×
235
                }
236
            }
237
        }
238
    }
×
239

240
    protected void onActivateElement(ILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase> element) {
241
        this.resetButton.setFocused(false);
×
242
        subGuiHolder.addSubGui(operatorInfoPattern = new SubGuiOperatorInfo(element));
×
243
        operatorInfoPattern.init(leftPos, topPos);
×
244
        subGuiHolder.addSubGui(operatorConfigPattern = element.createSubGui(ContainerLogicProgrammerBase.BASE_X, ContainerLogicProgrammerBase.BASE_Y, ContainerLogicProgrammerBase.MAX_WIDTH, ContainerLogicProgrammerBase.MAX_HEIGHT, this, (ContainerLogicProgrammerBase) getMenu()));
×
245
        operatorConfigPattern.init(leftPos, topPos);
×
246
    }
×
247

248
    protected void onDeactivateElement(ILogicProgrammerElement element) {
249
        subGuiHolder.clear();
×
250
    }
×
251

252
    public boolean handleElementActivation(ILogicProgrammerElement element, boolean sendToServer) {
253
        boolean activate = false;
×
254
        boolean deselect = false;
×
255
        ContainerLogicProgrammerBase container = getMenu();
×
256
        ILogicProgrammerElement newActive = null;
×
257
        if (container.getActiveElement() == element) {
×
258
            // Only allow deselection of the current LP element if the write slot is empty
259
            if (!container.hasWriteItemInSlot()) {
×
260
                deselect = true;
×
261
                onDeactivateElement(element);
×
262
            }
263
        } else {
264
            // Swap to another LP element
265
            onDeactivateElement(element);
×
266
            activate = true;
×
267
            newActive = element;
×
268
            if(element != null) {
×
269
                onActivateElement(element);
×
270
            }
271
        }
272
        resetButton.visible = newActive != null;
×
273
        if (activate || deselect) {
×
274
            container.setActiveElement(newActive,
×
275
                    operatorConfigPattern == null ? 0 : operatorConfigPattern.getX(),
×
276
                    operatorConfigPattern == null ? 0 : operatorConfigPattern.getY());
×
277
        }
278
        if (sendToServer) {
×
279
            if (newActive != null) {
×
280
                ILogicProgrammerElementType type = newActive.getType();
×
281
                IntegratedDynamics._instance.getPacketHandler().sendToServer(
×
282
                        new LogicProgrammerActivateElementPacket(type.getUniqueName(), type.getName(newActive)));
×
283
            } else if (deselect) {
×
284
                IntegratedDynamics._instance.getPacketHandler().sendToServer(
×
285
                        new LogicProgrammerActivateElementPacket(ResourceLocation.parse(""), ResourceLocation.parse("")));
×
286
            }
287
        }
288
        return activate;
×
289
    }
290

291
    @Nullable
292
    public RenderPattern getOperatorConfigPattern() {
293
        return operatorConfigPattern;
×
294
    }
295

296
    protected void setSearchFieldFocussed(boolean focused) {
297
        getSearchField().setFocused(focused);
×
298
    }
×
299

300
    protected boolean isSearchFieldFocussed() {
301
        return getSearchField().isFocused();
×
302
    }
303

304
    protected boolean selectPageElement(int elementId) {
305
        ContainerLogicProgrammerBase container = getMenu();
×
306

307
        // Deactivate current element
308
        if (elementId < 0) {
×
309
            handleElementActivation(container.getActiveElement(), true);
×
310
            return false;
×
311
        }
312

313
        // Activate a new element
314
        for(int i = 0; i < container.getPageSize(); i++) {
×
315
            if (container.isElementVisible(i)) {
×
316
                if (elementId-- == 0) {
×
317
                    ILogicProgrammerElement element = container.getVisibleElement(i);
×
318
                    if (container.getActiveElement() != element) {
×
319
                        handleElementActivation(element, true);
×
320
                    }
321
                    return true;
×
322
                }
323
            }
324
        }
325
        return false;
×
326
    }
327

328
    protected boolean handleKeyCode(int keyCode, int scanCode) {
329
        InputConstants.Key inputCode = InputConstants.getKey(keyCode, scanCode);
×
330
        if(keyCode != GLFW.GLFW_KEY_LEFT_SHIFT && keyCode != GLFW.GLFW_KEY_RIGHT_SHIFT) {
×
331
            ContainerLogicProgrammerBase container = getMenu();
×
332
            int pageSize = container.getPageSize();
×
333
            int stepModifier = MinecraftHelpers.isShifted() ? pageSize - 1 : 1;
×
334
            boolean isElementFocused = container.getActiveElement() != null && container.getActiveElement().isFocused(operatorConfigPattern);
×
335

336
            if (ClientProxy.FOCUS_LP_SEARCH.isActiveAndMatches(inputCode)) {
×
337
                // Focus search field
338
                setSearchFieldFocussed(true);
×
339
                swallowNextCharacter = true;
×
340
                return true;
×
341
            } else if (isElementFocused && ClientProxy.FOCUS_LP_RENAME.isActiveAndMatches(inputCode) && hasLabeller()) {
×
342
                // Open labeller gui
343
                operatorInfoPattern.onButtonEditClick();
×
344
                swallowNextCharacter = true;
×
345
                return true;
×
346
            } else if (GLFW.GLFW_KEY_LEFT == keyCode && (!isElementFocused && isSearchFieldFocussed())) {
×
347
                // Unfocus search field
348
                setSearchFieldFocussed(isSearchFieldFocussed());
×
349
                return true;
×
350
            } else if (!isElementFocused && GLFW.GLFW_KEY_DOWN == keyCode) {
×
351
                // Scroll down
352
                if (!selectPageElement(relativeStep += stepModifier)) {
×
353
                    relativeStep -= stepModifier;
×
354
                    if (relativeStep > 0) {
×
355
                        getScrollbar().scrollRelative(-stepModifier);
×
356
                        selectPageElement(relativeStep);
×
357
                    }
358
                }
359
                return true;
×
360
            } else if (!isElementFocused && GLFW.GLFW_KEY_UP == keyCode) {
×
361
                // Scroll up
362
                if (!(relativeStep >= 0 && selectPageElement(relativeStep -= stepModifier))) {
×
363
                    getScrollbar().scrollRelative(stepModifier);
×
364
                    selectPageElement(relativeStep = 0);
×
365
                }
366
                return true;
×
367
            } else if (!isElementFocused
×
368
                    && (GLFW.GLFW_KEY_RIGHT == keyCode || GLFW.GLFW_KEY_TAB == keyCode
369
                    || GLFW.GLFW_KEY_ENTER == keyCode || GLFW.GLFW_KEY_KP_ENTER == keyCode)) {
370
                if (container.getActiveElement() != null) {
×
371
                    container.getActiveElement().setFocused(operatorConfigPattern, true);
×
372
                    setSearchFieldFocussed(false);
×
373
                }
374
                return true;
×
375
            }
376
        }
377
        return false;
×
378
    }
379

380
    @Override
381
    public boolean charTyped(char keyCode, int scanCode) {
382
        if (swallowNextCharacter) {
×
383
            swallowNextCharacter = false;
×
384
            return true;
×
385
        }
386

387
        return subGuiHolder.charTyped(keyCode, scanCode) || handleKeyCode(keyCode, scanCode) || super.charTyped(keyCode, scanCode);
×
388
    }
389

390
    @Override
391
    public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
392
        if (keyCode != GLFW.GLFW_KEY_ESCAPE) {
×
393
            if (this.subGuiHolder.keyPressed(keyCode, scanCode, modifiers) || handleKeyCode(keyCode, scanCode)) {
×
394
                return true;
×
395
            }
396
        }
397
        return super.keyPressed(keyCode, scanCode, modifiers);
×
398
    }
399

400
    @Override
401
    public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
402
        if (subGuiHolder.mouseClicked(mouseX, mouseY, mouseButton)) {
×
403
            if (isSearchFieldFocussed()) {
×
404
                setSearchFieldFocussed(false);
×
405
            }
406
            return true;
×
407
        }
408

409
        ContainerLogicProgrammerBase container = getMenu();
×
410
        for(int i = 0; i < container.getPageSize(); i++) {
×
411
            if (container.isElementVisible(i)) {
×
412
                ILogicProgrammerElement element = container.getVisibleElement(i);
×
413
                if (isPointInRegion(getElementPosition(container, i, false), new Point((int) mouseX, (int) mouseY))) {
×
414
                    boolean activated = handleElementActivation(element, true);
×
415
                    relativeStep = activated ? i : -1;
×
416
                    if (activated) {
×
417
                        container.getActiveElement().setFocused(operatorConfigPattern, true);
×
418
                        setSearchFieldFocussed(false);
×
419
                        return true;
×
420
                    }
421
                }
422
            }
423
        }
424
        boolean superRet = super.mouseClicked(mouseX, mouseY, mouseButton);
×
425

426
        // If the search box has been selected, de-active the current element.
427
        if(isSearchFieldFocussed() &&
×
428
                container.getActiveElement() != null && container.getActiveElement().isFocused(operatorConfigPattern)) {
×
429
            container.getActiveElement().setFocused(operatorConfigPattern, false);
×
430
            return true;
×
431
        }
432

433
        return superRet;
×
434
    }
435

436
    protected void label(String label) {
437
        IntegratedDynamics._instance.getPacketHandler().sendToServer(new LogicProgrammerLabelPacket(label));
×
438
    }
×
439

440
    protected boolean hasLabeller() {
441
        return this.hasLabeller;
×
442
    }
443

444
    public class SubGuiOperatorInfo extends GuiElementValueTypeString.SubGuiValueTypeInfo<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase> {
445

446
        private WidgetTextFieldExtended searchField;
447
        private ButtonText button = null;
×
448

449
        public SubGuiOperatorInfo(IGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase> element) {
×
450
            super(ContainerScreenLogicProgrammerBase.this, getMenu(), element, 88, 106, 139, 20);
×
451

452
            if(hasLabeller()) {
×
453
                buttonList.add(button = new ButtonText(0, 0, 6, 10, Component.translatable("gui.integrateddynamics.button.edit"), Component.literal("E"),
×
454
                        (button) -> onButtonEditClick(), true));
×
455
            }
456

457
            int searchWidth = 113;
×
458
            this.searchField = new WidgetTextFieldExtended(ContainerScreenLogicProgrammerBase.this.font, 0, 0, searchWidth, 11,
×
459
                    Component.translatable("gui.cyclopscore.search"));
×
460
            this.searchField.setMaxLength(64);
×
461
            this.searchField.setBordered(true);
×
462
            this.searchField.setVisible(false);
×
463
            this.searchField.setTextColor(16777215);
×
464
            this.searchField.setCanLoseFocus(true);
×
465
            this.searchField.setValue("");
×
466
            this.searchField.setWidth(searchWidth);
×
467
        }
×
468

469
        @Override
470
        public void init(int guiLeft, int guiTop) {
471
            super.init(guiLeft, guiTop);
×
472
            int searchX = 90;
×
473
            int searchY = 110;
×
474
            this.searchField.setX(guiLeft + searchX);
×
475
            this.searchField.setY(guiTop + searchY);
×
476

477
            if (hasLabeller()) {
×
478
                button.setX(guiLeft + 220);
×
479
                button.setY(guiTop + 111);
×
480
            }
481
        }
×
482

483
        @Override
484
        protected boolean showError() {
485
            return container.canWriteActiveElementPre();
×
486
        }
487

488
        @Override
489
        protected Component getLastError() {
490
            return container.getLastError();
×
491
        }
492

493
        @Override
494
        protected ResourceLocation getTexture() {
495
            return texture;
×
496
        }
497

498
        @Override
499
        public boolean charTyped(char typedChar, int keyCode) {
500
            if (!this.searchField.isFocused() || !this.searchField.charTyped(typedChar, keyCode)) {
×
501
                return super.charTyped(typedChar, keyCode);
×
502
            } else {
503
                label(this.searchField.getValue());
×
504
                return true;
×
505
            }
506
        }
507

508
        @Override
509
        public boolean keyPressed(int typedChar, int keyCode, int modifiers) {
510
            if (this.searchField.isFocused() && typedChar != GLFW.GLFW_KEY_ESCAPE) {
×
511
                this.searchField.keyPressed(typedChar, keyCode, modifiers);
×
512
                label(this.searchField.getValue());
×
513
                return true;
×
514
            }
515
            return super.keyPressed(typedChar, keyCode, modifiers);
×
516
        }
517

518
        @Override
519
        public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
520
            if(this.searchField.isVisible() && this.searchField.mouseClicked(mouseX, mouseY, mouseButton)) {
×
521
                return true;
×
522
            }
523
            return super.mouseClicked(mouseX, mouseY, mouseButton);
×
524
        }
525

526
        @Override
527
        public void renderBg(GuiGraphics guiGraphics, int guiLeft, int guiTop, TextureManager textureManager, Font font, float partialTicks, int mouseX, int mouseY) {
528
            super.renderBg(guiGraphics, guiLeft, guiTop, textureManager, font, partialTicks, mouseX, mouseY);
×
529
            this.searchField.render(guiGraphics, mouseX, mouseY, partialTicks);
×
530
        }
×
531

532
        @Override
533
        public boolean shouldRenderElementName() {
534
            return !this.searchField.isVisible();
×
535
        }
536

537
        public void onButtonEditClick() {
538
            this.searchField.setVisible(!this.searchField.isVisible());
×
539
            if(this.searchField.isVisible()) {
×
540
                this.searchField.setFocused(true);
×
541
                label(this.searchField.getValue());
×
542
            } else {
543
                label("");
×
544
            }
545
        }
×
546
    }
547

548
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc