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

CyclopsMC / IntegratedDynamics / 15366166327

31 May 2025 05:58PM UTC coverage: 44.766% (-0.5%) from 45.303%
15366166327

push

github

rubensworks
Bump mod version

2565 of 8515 branches covered (30.12%)

Branch coverage included in aggregate %.

11734 of 23427 relevant lines covered (50.09%)

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
                this.drawTooltip(Lists.newArrayList(Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_TOOLTIP_WRITESLOT_MODIFY)), guiGraphics.pose(), mouseX - this.leftPos, mouseY - this.topPos);
×
222
            }
223
        }
224

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

432
        return superRet;
×
433
    }
434

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

547
}
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