From f9a7649b0e31cf3f40f073a7d9a3d1fffa151a13 Mon Sep 17 00:00:00 2001 From: GiantLuigi4 <49770992+GiantLuigi4@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:03:50 -0400 Subject: [PATCH] optimize minepad model and texture --- .../net/montoyo/wd/block/BlockServer.java | 2 +- .../net/montoyo/wd/client/gui/GuiServer.java | 97 +++++++++++++----- .../wd/client/renderers/ModelMinePad.java | 2 +- .../java/net/montoyo/wd/init/BlockInit.java | 13 ++- .../webdisplays/models/item/minepad.json | 2 +- .../webdisplays/textures/models/minepad.png | Bin 341 -> 255 bytes .../textures/models/minepad_item.png | Bin 123 -> 290 bytes 7 files changed, 80 insertions(+), 36 deletions(-) diff --git a/src/main/java/net/montoyo/wd/block/BlockServer.java b/src/main/java/net/montoyo/wd/block/BlockServer.java index 3582f4a..d19e2da 100644 --- a/src/main/java/net/montoyo/wd/block/BlockServer.java +++ b/src/main/java/net/montoyo/wd/block/BlockServer.java @@ -76,7 +76,7 @@ public class BlockServer extends WDBlockContainer{ if(te instanceof TileEntityServer) { ((TileEntityServer) te).onPlayerRightClick(player); - return InteractionResult.PASS; + return InteractionResult.SUCCESS; } else return InteractionResult.FAIL; } diff --git a/src/main/java/net/montoyo/wd/client/gui/GuiServer.java b/src/main/java/net/montoyo/wd/client/gui/GuiServer.java index 7022b75..6803368 100644 --- a/src/main/java/net/montoyo/wd/client/gui/GuiServer.java +++ b/src/main/java/net/montoyo/wd/client/gui/GuiServer.java @@ -50,7 +50,7 @@ public class GuiServer extends WDScreen { private final Vector3i serverPos; private final NameUUIDPair owner; private final ArrayList lines = new ArrayList<>(); - private String prompt = "<"; + private String prompt = ""; private String userPrompt; private int blinkTime; private String lastCmd; @@ -87,7 +87,7 @@ public class GuiServer extends WDScreen { lines.add(tr("info")); uploadCD(FileSystemView.getFileSystemView().getDefaultDirectory()); } - + private static String tr(String key, Object ... args) { return I18n.get("webdisplays.server." + key, args); } @@ -118,8 +118,12 @@ public class GuiServer extends WDScreen { } if(!promptLocked) { - x = font.drawShadow(poseStack, userPrompt, x, y, 0xFFFFFFFF, false); - x = font.drawShadow(poseStack, prompt, x, y, 0xFFFFFFFF, false); + if (queue.isEmpty()) { + x = font.drawShadow(poseStack, userPrompt, x, y, 0xFFFFFFFF, false); + x = font.drawShadow(poseStack, prompt, x, y, 0xFFFFFFFF, false); + } else { + x = font.drawShadow(poseStack, "", x, y, 0xFFFFFFFF, false); + } } if(!uploadWizard && blinkTime < 5) @@ -198,6 +202,19 @@ public class GuiServer extends WDScreen { uploadFilter = ""; } } + + final int maxl = uploadWizard ? MAX_LINES : (MAX_LINES - 1); //Cuz prompt is hidden + if (!queue.isEmpty()) { + while (!queue.isEmpty()) { + if (lines.size() >= maxl) { + break; + } + writeLine(queue.remove(0)); + } + } + while (lines.size() > maxl) { + lines.remove(0); + } } @Override @@ -205,7 +222,7 @@ public class GuiServer extends WDScreen { Supplier predicate = () -> super.keyReleased(keyCode, scanCode, modifiers); try { - return handleKeyboardInput(keyCode, true, predicate); + return handleKeyboardInput(keyCode, false, predicate); } catch (IOException e) { e.printStackTrace(); return false; @@ -214,6 +231,11 @@ public class GuiServer extends WDScreen { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (keyCode == GLFW.GLFW_KEY_ESCAPE) { + Minecraft.getInstance().setScreen(null); + return true; + } + getChar(keyCode, scanCode).ifPresent(c -> { try { keyTyped(c, keyCode, modifiers); @@ -231,6 +253,9 @@ public class GuiServer extends WDScreen { } public boolean handleKeyboardInput(int keyCode, boolean keyState, Supplier booleanSupplier) throws IOException { + if (!queue.isEmpty()) + return false; + if(uploadWizard) { if(keyState) { if(keyCode == GLFW.GLFW_KEY_UP) { @@ -315,42 +340,51 @@ public class GuiServer extends WDScreen { protected void keyTyped(char typedChar, int keyCode, int modifier) throws IOException { //this.charTyped(typedChar, modifier); - - if(uploadWizard) { + + if (keyCode == GLFW.GLFW_KEY_DOWN) { + if (!queue.isEmpty()) { + writeLine(queue.remove(0)); + return; + } + } + if (!queue.isEmpty()) + return; + + if (uploadWizard) { boolean found = false; uploadFilter += Character.toLowerCase(typedChar); uploadFilterTime = System.currentTimeMillis(); - - for(int i = uploadFirstIsParent ? 1 : 0; i < uploadFiles.size(); i++) { - if(uploadFiles.get(i).getName().toLowerCase().startsWith(uploadFilter)) { + + for (int i = uploadFirstIsParent ? 1 : 0; i < uploadFiles.size(); i++) { + if (uploadFiles.get(i).getName().toLowerCase().startsWith(uploadFilter)) { selectFile(i); found = true; break; } } - - if(!found && uploadFilter.length() == 1) + + if (!found && uploadFilter.length() == 1) uploadFilter = ""; - + return; - } else if(promptLocked) + } else if (promptLocked) return; - - if(keyCode == GLFW.GLFW_KEY_BACKSPACE) { - if(prompt.length() > 0) + + if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { + if (prompt.length() > 0) prompt = prompt.substring(0, prompt.length() - 1); - } else if(keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) { - if(prompt.length() > 0) { + } else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) { + if (prompt.length() > 0) { writeLine(userPrompt + prompt); evaluateCommand(prompt); lastCmd = prompt; prompt = ""; } else writeLine(userPrompt); - } else if(prompt.length() + 1 < MAX_LINE_LEN && typedChar >= 32 && typedChar <= 126) - + } else if (prompt.length() + 1 < MAX_LINE_LEN && typedChar >= 32 && typedChar <= 126) + prompt = prompt + typedChar; - + blinkTime = 0; } @@ -453,16 +487,18 @@ public class GuiServer extends WDScreen { @CommandHandler("help") public void commandHelp(String[] args) { + queueRead = lines.size(); + if(args.length > 0) { String cmd = args[0].toLowerCase(); if(COMMAND_MAP.containsKey(cmd)) - writeLine(tr("help." + cmd)); + queueLine(tr("help." + cmd)); else - writeLine(tr("unknowncmd")); + queueLine(tr("unknowncmd")); } else { for(String c : COMMAND_MAP.keySet()) - writeLine(c + " - " + tr("help." + c)); + queueLine(c + " - " + tr("help." + c)); } } @@ -744,5 +780,14 @@ public class GuiServer extends WDScreen { public String getWikiPageName() { return "Server"; } - + + int queueRead = 0; + ArrayList queue = new ArrayList<>(); + + private void queueLine(String line) { + if (queueRead > 1) { + writeLine(line); + queueRead -= 1; + } else queue.add(line); + } } diff --git a/src/main/java/net/montoyo/wd/client/renderers/ModelMinePad.java b/src/main/java/net/montoyo/wd/client/renderers/ModelMinePad.java index b043653..bcfa0de 100644 --- a/src/main/java/net/montoyo/wd/client/renderers/ModelMinePad.java +++ b/src/main/java/net/montoyo/wd/client/renderers/ModelMinePad.java @@ -41,7 +41,7 @@ public final class ModelMinePad { t.end(); int width = 32; - int height = 16; + int height = 32; float padding = 1f / 23; float padding1 = 1f / 21; diff --git a/src/main/java/net/montoyo/wd/init/BlockInit.java b/src/main/java/net/montoyo/wd/init/BlockInit.java index 61befff..00fe5b4 100644 --- a/src/main/java/net/montoyo/wd/init/BlockInit.java +++ b/src/main/java/net/montoyo/wd/init/BlockInit.java @@ -8,7 +8,6 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import net.montoyo.wd.block.*; -import net.montoyo.wd.core.DefaultPeripheral; public class BlockInit { @@ -18,14 +17,14 @@ public class BlockInit { public static DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "webdisplays"); - public static final RegistryObject blockScreen = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.of(Material.STONE))); + public static final RegistryObject blockScreen = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.of(Material.STONE))); - public static final RegistryObject blockKeyBoard = BlockInit.BLOCKS.register("kb_left", BlockKeyboardLeft::new); - public static final RegistryObject blockKbRight = BLOCKS.register("kb_right", BlockKeyboardRight::new); + public static final RegistryObject blockKeyBoard = BlockInit.BLOCKS.register("kb_left", BlockKeyboardLeft::new); + public static final RegistryObject blockKbRight = BLOCKS.register("kb_right", BlockKeyboardRight::new); - public static final RegistryObject blockRedControl = BlockInit.BLOCKS.register("redctrl", BlockRedCTRL::new); + public static final RegistryObject blockRedControl = BlockInit.BLOCKS.register("redctrl", BlockRedCTRL::new); - public static final RegistryObject blockRControl = BlockInit.BLOCKS.register("rctrl", BlockRCTRL::new); + public static final RegistryObject blockRControl = BlockInit.BLOCKS.register("rctrl", BlockRCTRL::new); - public static final RegistryObject blockServer = BlockInit.BLOCKS.register("server", BlockServer::new); + public static final RegistryObject blockServer = BlockInit.BLOCKS.register("server", BlockServer::new); } diff --git a/src/main/resources/assets/webdisplays/models/item/minepad.json b/src/main/resources/assets/webdisplays/models/item/minepad.json index b49bd20..d2f99a4 100644 --- a/src/main/resources/assets/webdisplays/models/item/minepad.json +++ b/src/main/resources/assets/webdisplays/models/item/minepad.json @@ -1 +1 @@ -{"credit":"Made with Blockbench","texture_size":[64,32],"textures":{"0":"webdisplays:models/minepad"},"elements":[{"from":[1,0,0],"to":[15,1,9],"rotation":{"angle":0,"axis":"y","origin":[1,0,3.5]},"faces":{"north":{"uv":[2.25,4.5,5.75,5],"texture":"#0"},"east":{"uv":[0,4.5,2.25,5],"texture":"#0"},"south":{"uv":[8,4.5,11.5,5],"texture":"#0"},"west":{"uv":[5.75,4.5,8,5],"texture":"#0"},"up":{"uv":[5.75,4.5,2.25,0],"texture":"#0"},"down":{"uv":[9.25,0,5.75,4.5],"texture":"#0"}}},{"from":[0,0,1],"to":[1,1,8],"rotation":{"angle":0,"axis":"y","origin":[0,0,4.5]},"faces":{"north":{"uv":[1.75,8.5,2,9],"texture":"#0"},"east":{"uv":[0,8.5,1.75,9],"texture":"#0"},"south":{"uv":[3.75,8.5,4,9],"texture":"#0"},"west":{"uv":[2,8.5,3.75,9],"texture":"#0"},"up":{"uv":[2,8.5,1.75,5],"texture":"#0"},"down":{"uv":[2.25,5,2,8.5],"texture":"#0"}}},{"from":[15,0,1],"to":[16,1,8],"rotation":{"angle":0,"axis":"y","origin":[15,0,4.5]},"faces":{"north":{"uv":[9.25,8.5,9.5,9],"texture":"#0"},"east":{"uv":[7.5,8.5,9.25,9],"texture":"#0"},"south":{"uv":[11.25,8.5,11.5,9],"texture":"#0"},"west":{"uv":[9.5,8.5,11.25,9],"texture":"#0"},"up":{"uv":[9.5,8.5,9.25,5],"texture":"#0"},"down":{"uv":[9.75,5,9.5,8.5],"texture":"#0"}}}],"display":{"thirdperson_righthand":{"rotation":[95.5,-180,0],"translation":[0,6.75,9]},"thirdperson_lefthand":{"rotation":[95.5,-180,0],"translation":[0,6.75,9]},"ground":{"rotation":[-90,0,0],"translation":[0,11.5,-7.6]},"gui":{"rotation":[90,0,0],"translation":[0,-3.5,0]},"head":{"rotation":[-90,0,0],"translation":[0,14.25,-0.75]},"fixed":{"rotation":[-90,0,0],"translation":[0,0,-7.5]}},"groups":[{"name":"bone","origin":[0,0,0],"color":0,"children":[0,1,2]}]} \ No newline at end of file +{"credit":"Made with Blockbench","texture_size":[32,16],"textures":{"1":"webdisplays:models/minepad","particle":"webdisplays:models/minepad"},"elements":[{"from":[1,0,0],"to":[15,1,9],"rotation":{"angle":0,"axis":"y","origin":[1,0,3.5]},"faces":{"north":{"uv":[0,9,7,10],"texture":"#1"},"east":{"uv":[13.5,0,14,9],"rotation":270,"texture":"#1"},"south":{"uv":[7,9,14,10],"texture":"#1"},"west":{"uv":[7,0,7.5,9],"rotation":90,"texture":"#1"},"up":{"uv":[7,9,0,0],"texture":"#1"},"down":{"uv":[13.5,0,7.5,9],"texture":"#1"}}},{"from":[15,0,1],"to":[16,1,8],"rotation":{"angle":0,"axis":"y","origin":[15,0,4.5]},"faces":{"north":{"uv":[8.5,13,8,14],"texture":"#1"},"east":{"uv":[9,12,5.5,11],"texture":"#1"},"south":{"uv":[9,13,8.5,14],"texture":"#1"},"up":{"uv":[9,11,5.5,10],"texture":"#1"},"down":{"uv":[9,13,5.5,12],"texture":"#1"}}},{"from":[0,0,1],"to":[1,1,8],"rotation":{"angle":0,"axis":"y","origin":[15,0,4.5]},"faces":{"north":{"uv":[5,13,4.5,14],"texture":"#1"},"south":{"uv":[5.5,13,5,14],"texture":"#1"},"west":{"uv":[5.5,12,2,11],"texture":"#1"},"up":{"uv":[5.5,11,2,10],"texture":"#1"},"down":{"uv":[5.5,13,2,12],"texture":"#1"}}}],"display":{"thirdperson_righthand":{"rotation":[95.5,-180,0],"translation":[0,6.75,9]},"thirdperson_lefthand":{"rotation":[95.5,-180,0],"translation":[0,6.75,9]},"ground":{"rotation":[-90,0,0],"translation":[0,11.5,-7.6]},"gui":{"rotation":[90,0,0],"translation":[0,-3.5,0]},"head":{"rotation":[-90,0,0],"translation":[0,14.25,-0.75]},"fixed":{"rotation":[-90,0,0],"translation":[0,0,-7.5]}},"groups":[{"name":"bone","origin":[0,0,0],"color":0,"children":[0,1,2]}]} \ No newline at end of file diff --git a/src/main/resources/assets/webdisplays/textures/models/minepad.png b/src/main/resources/assets/webdisplays/textures/models/minepad.png index c7a4b39828a0e825ab1ee5f19823a4f6dff0eec8..eedbdd9d173196530bf202367dd761b3fc86d57f 100644 GIT binary patch literal 255 zcmV+Gv6jT&mghTH!D52&6R#3SqGI25{DjK6rUbQT{@L6C55iw50IVWDn z(mA(lAtHM72_ayuh1MD=CBzuPynMdfuH9#_*1{MADJ9yrMbk8^Ifn|+T93B(9>Xx4 zD3iZ2SNK002ovPDHLk FV1jz`V)g(4 literal 341 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQfx`y?k)`fL2$v|<&%LToCO|{ z#S9F5M?jcysy3fAP>{XE)7O>#0XM&}r1AO5u1-LqN1iT@AsP4H-Y^tuRuEyiaCBj@ z44;Fe>qA!?lj93oW-&)(KJ{N3s-~HwaO`f^J8OUY&5M~7DkcjsWu?tpmbLkdx%>;s zIYC_asw1)ky&TU;Dm8_@%;NuY@31BNTGO^fhx^|%X1-#$cI&ZB@{w)1-I-IW^oj#WX)LsM}nOR~>p?hPlo-WVP`U|HTP`ooQX#&b!-W6v10 zS`>C9oYV4t6)Jq^e$CmmuSbNj0g%>2()w~oDlmBWF7NuU8N4rV^^ b|IDyrt*7l3?axv`-!gc*`njxgN@xNAQ~`ZT diff --git a/src/main/resources/assets/webdisplays/textures/models/minepad_item.png b/src/main/resources/assets/webdisplays/textures/models/minepad_item.png index 5f55fc81b1ebef3896a627e674d327bc6318cf56..25bec6f1a980abef3f8816252cf95a75cfebe4f9 100644 GIT binary patch delta 275 zcmV+u0qp*Jq5_Z?e;^130001UdV2H#008MpL_t(oh3%EG4Z|Q1MgK)~mc;-RR1{vs zUMp*vF({#C09SV9OA*Ocq6Bh@rHEHiVEz+6eaL&y%nS*L2;(?X$v29bF-_A|LSUZf z;&Uz%!Ji;1KvZ=5@&Yxp^k2WA2{eHk6cJT5*duCsfB?XIe=qVFl)eK1KvLng66)0k zB7$=c#u((Bky5H^yl1=|LgyT;wNOf-?|XDzCl>yefHCG+hY+yu`)>tu&c}Kf2GMZf zjTuNO0l449wryC~^|u1dj2I(gjL=$(4j@p_gj#D@YemD01eRq%2;n?|Z*h7RHyVw` Z4MM$4wFcfI4Y~jT002ovPDHLkV1iJbbBO=| delta 106 zcmZ3)R6RjFMSz2ifq|i%p*9joIeEG`hIn`K+_mJUHx3v IIVCg!01;Os`~Uy|