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

CyclopsMC / IntegratedDynamics / 15509513573

07 Jun 2025 04:05PM UTC coverage: 45.14% (-0.04%) from 45.175%
15509513573

push

github

rubensworks
Merge remote-tracking branch 'origin/master-1.21-lts' into master-1.21

2564 of 8512 branches covered (30.12%)

Branch coverage included in aggregate %.

11917 of 23568 relevant lines covered (50.56%)

2.4 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 net.minecraft.client.Minecraft;
6
import net.minecraft.client.gui.Font;
7
import net.minecraft.client.gui.GuiGraphics;
8
import net.minecraft.client.renderer.RenderType;
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.util.ARGB;
14
import net.minecraft.world.entity.player.Inventory;
15
import net.minecraft.world.item.ItemStack;
16
import org.apache.commons.lang3.tuple.Triple;
17
import org.cyclops.cyclopscore.client.gui.component.button.ButtonText;
18
import org.cyclops.cyclopscore.client.gui.component.input.WidgetTextFieldExtended;
19
import org.cyclops.cyclopscore.client.gui.container.ContainerScreenScrolling;
20
import org.cyclops.cyclopscore.client.gui.image.Images;
21
import org.cyclops.cyclopscore.helper.IModHelpers;
22
import org.cyclops.integrateddynamics.IntegratedDynamics;
23
import org.cyclops.integrateddynamics.Reference;
24
import org.cyclops.integrateddynamics.RegistryEntries;
25
import org.cyclops.integrateddynamics.api.client.gui.subgui.IGuiInputElement;
26
import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElement;
27
import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElementType;
28
import org.cyclops.integrateddynamics.core.client.gui.subgui.SubGuiHolder;
29
import org.cyclops.integrateddynamics.core.evaluate.variable.gui.GuiElementValueTypeString;
30
import org.cyclops.integrateddynamics.core.helper.L10NValues;
31
import org.cyclops.integrateddynamics.core.logicprogrammer.LogicProgrammerElementTypes;
32
import org.cyclops.integrateddynamics.core.logicprogrammer.RenderPattern;
33
import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase;
34
import org.cyclops.integrateddynamics.network.packet.LogicProgrammerActivateElementPacket;
35
import org.cyclops.integrateddynamics.network.packet.LogicProgrammerLabelPacket;
36
import org.cyclops.integrateddynamics.proxy.ClientProxy;
37
import org.lwjgl.glfw.GLFW;
38

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

148
        // Draw container name
149
        guiGraphics.drawString(font, Component.translatable(L10NValues.GUI_LOGICPROGRAMMER_FILTER),
×
150
                this.leftPos + offsetX + 5, this.topPos + offsetY + 208, IModHelpers.get().getBaseHelpers().RGBToInt(80, 80, 80),
×
151
                false);
152

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

160
                Triple<Float, Float, Float> rgb = IModHelpers.get().getBaseHelpers().intToRGB(element.getColor());
×
161
                boolean hover = LogicProgrammerElementTypes.areEqual(container.getActiveElement(), element)
×
162
                        || isPointInRegion(getElementPosition(container, i, false), new Point(mouseX, mouseY));
×
163
                int color = ARGB.colorFromFloat(
×
164
                        1F,
165
                        colorSmoothener(rgb.getLeft(), hover),
×
166
                        colorSmoothener(rgb.getMiddle(), hover),
×
167
                        colorSmoothener(rgb.getRight(), hover)
×
168
                );
169

170
                // Background
171
                guiGraphics.blit(RenderType::guiTextured, texture, leftPos + offsetX + ITEM_POSITION.x,
×
172
                        topPos + offsetY + ITEM_POSITION.y + boxHeight * i, 19, 18, ITEM_POSITION.width, ITEM_POSITION.height, 256, 256, color);
173

174
                // Arrow
175
                if(hover) {
×
176
                    guiGraphics.blit(RenderType::guiTextured, texture, leftPos + offsetX + ITEM_POSITION.x,
×
177
                            topPos + offsetY + ITEM_POSITION.y + boxHeight * i, 0, 240, 3, 16, 256, 256, color);
178
                }
179

180
                // Operator info
181
                String aspectName = element.getSymbol();
×
182
                IModHelpers.get().getRenderHelpers().drawScaledCenteredString(guiGraphics, font, aspectName,
×
183
                        this.leftPos + offsetX + (hover ? 22 : 21),
×
184
                        this.topPos + offsetY + 26 + boxHeight * i,
185
                        53, IModHelpers.get().getBaseHelpers().RGBToInt(40, 40, 40), false, Font.DisplayMode.NORMAL);
×
186
            }
187
        }
188

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

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

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

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

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

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

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

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

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

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

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

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

302
    protected boolean isSearchFieldFocussed() {
303
        return getSearchField().isFocused();
×
304
    }
305

306
    protected boolean selectPageElement(int elementId) {
307
        ContainerLogicProgrammerBase container = getMenu();
×
308

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

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

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

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

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

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

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

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

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

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

435
        return superRet;
×
436
    }
437

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

442
    protected boolean hasLabeller() {
443
        return this.hasLabeller;
×
444
    }
445

446
    public class SubGuiOperatorInfo extends GuiElementValueTypeString.SubGuiValueTypeInfo<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase> {
447

448
        private WidgetTextFieldExtended searchField;
449
        private ButtonText button = null;
×
450

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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