server wont delete history

This commit is contained in:
amy 2024-07-16 22:42:07 +03:30
parent d1abbeec7b
commit c5ff6a2c4f
2 changed files with 12 additions and 7 deletions

View file

@ -80,9 +80,6 @@ public class ComputerBlockEntity extends BlockEntity {
} else { } else {
lines.add("Made unknown!"); lines.add("Made unknown!");
} }
while (lines.size() > screen.dimensions().rows() - 1 && !lines.isEmpty()) {
lines.removeFirst();
}
} }
public ComputerScreenUpdate getSyncPacket(int windowId) { public ComputerScreenUpdate getSyncPacket(int windowId) {

View file

@ -1,5 +1,6 @@
package dev.exhq.ajarc.computer; package dev.exhq.ajarc.computer;
import com.mojang.blaze3d.platform.InputConstants;
import dev.exhq.ajarc.network.ComputerCommandSent; import dev.exhq.ajarc.network.ComputerCommandSent;
import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
@ -22,7 +23,7 @@ public class ComputerScreen extends AbstractContainerScreen<ComputerMenu> {
@Override @Override
protected void init() { protected void init() {
imageHeight = menu.getRows() * 11 - 1; imageHeight = (menu.getRows() * 11) - 1;
imageWidth = menu.getColumns() * 10; imageWidth = menu.getColumns() * 10;
super.init(); super.init();
} }
@ -42,7 +43,9 @@ public class ComputerScreen extends AbstractContainerScreen<ComputerMenu> {
@Override @Override
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { 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; return true;
if (pKeyCode == GLFW.GLFW_KEY_ENTER) { if (pKeyCode == GLFW.GLFW_KEY_ENTER) {
var toSend = editingLine; var toSend = editingLine;
@ -50,14 +53,19 @@ public class ComputerScreen extends AbstractContainerScreen<ComputerMenu> {
menu.sendLineToServer(toSend); menu.sendLineToServer(toSend);
return true; return true;
} }
if (pKeyCode == GLFW.GLFW_KEY_BACKSPACE && !editingLine.isEmpty()) {
editingLine = editingLine.substring(0, editingLine.length() - 1);
}
return false; return false;
} }
@Override @Override
protected void renderLabels(@NotNull GuiGraphics graphics, int pMouseX, int pMouseY) { protected void renderLabels(@NotNull GuiGraphics graphics, int pMouseX, int pMouseY) {
int offsetY = 0; int offsetY = 0;
for (String line : menu.getLines()) { var lines = menu.getLines();
graphics.drawString(font, line, 0, offsetY, 0xFFFFFFFF); //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; offsetY += 11;
} }
graphics.drawString(font, "$ " + editingLine, 0, offsetY, 0xFFFFFFFF); graphics.drawString(font, "$ " + editingLine, 0, offsetY, 0xFFFFFFFF);