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

CyclopsMC / IntegratedDynamics / 15366205963

31 May 2025 06:03PM UTC coverage: 45.019% (-0.5%) from 45.524%
15366205963

push

github

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

2555 of 8509 branches covered (30.03%)

Branch coverage included in aggregate %.

11885 of 23566 relevant lines covered (50.43%)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

434
        return superRet;
×
435
    }
436

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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