diff --git a/src/main/java/dev/exhq/ajarc/computer/ComputerBlockEntity.java b/src/main/java/dev/exhq/ajarc/computer/ComputerBlockEntity.java index a16d5c3..7d08981 100644 --- a/src/main/java/dev/exhq/ajarc/computer/ComputerBlockEntity.java +++ b/src/main/java/dev/exhq/ajarc/computer/ComputerBlockEntity.java @@ -80,9 +80,6 @@ public class ComputerBlockEntity extends BlockEntity { } else { lines.add("Made unknown!"); } - while (lines.size() > screen.dimensions().rows() - 1 && !lines.isEmpty()) { - lines.removeFirst(); - } } public ComputerScreenUpdate getSyncPacket(int windowId) { diff --git a/src/main/java/dev/exhq/ajarc/computer/ComputerScreen.java b/src/main/java/dev/exhq/ajarc/computer/ComputerScreen.java index 1c057fa..b910b28 100644 --- a/src/main/java/dev/exhq/ajarc/computer/ComputerScreen.java +++ b/src/main/java/dev/exhq/ajarc/computer/ComputerScreen.java @@ -1,5 +1,6 @@ package dev.exhq.ajarc.computer; +import com.mojang.blaze3d.platform.InputConstants; import dev.exhq.ajarc.network.ComputerCommandSent; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -22,7 +23,7 @@ public class ComputerScreen extends AbstractContainerScreen { @Override protected void init() { - imageHeight = menu.getRows() * 11 - 1; + imageHeight = (menu.getRows() * 11) - 1; imageWidth = menu.getColumns() * 10; super.init(); } @@ -42,7 +43,9 @@ public class ComputerScreen extends AbstractContainerScreen { @Override public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { - if (super.keyPressed(pKeyCode, pScanCode, pModifiers)) + InputConstants.Key mouseKey = InputConstants.getKey(pKeyCode, pScanCode); + assert this.minecraft != null; + if (!this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey) && super.keyPressed(pKeyCode, pScanCode, pModifiers)) return true; if (pKeyCode == GLFW.GLFW_KEY_ENTER) { var toSend = editingLine; @@ -50,14 +53,19 @@ public class ComputerScreen extends AbstractContainerScreen { menu.sendLineToServer(toSend); return true; } + if (pKeyCode == GLFW.GLFW_KEY_BACKSPACE && !editingLine.isEmpty()) { + editingLine = editingLine.substring(0, editingLine.length() - 1); + } return false; } @Override protected void renderLabels(@NotNull GuiGraphics graphics, int pMouseX, int pMouseY) { int offsetY = 0; - for (String line : menu.getLines()) { - graphics.drawString(font, line, 0, offsetY, 0xFFFFFFFF); + var lines = menu.getLines(); + //var renderedlines = lines.subList(lines.size() - menu.getRows(), lines.size()); + for (int i = Math.max(0, lines.size() - menu.getRows() + 1); i < lines.size(); i++) { + graphics.drawString(font, lines.get(i), 0, offsetY, 0xFFFFFFFF); offsetY += 11; } graphics.drawString(font, "$ " + editingLine, 0, offsetY, 0xFFFFFFFF);