From 8d465262209925c2cea5c16196cf3a9c20112b09 Mon Sep 17 00:00:00 2001 From: lothrazar Date: Sun, 13 Oct 2024 13:18:37 -0700 Subject: [PATCH] fix item tooltips in remote not rendering --- gradle.properties | 2 +- .../inventory/ScreenNetworkInventory.java | 7 ++-- .../block/request/ScreenNetworkTable.java | 6 ++- .../storagenetwork/gui/TextboxInteger.java | 5 ++- .../remote/ScreenNetworkCraftingRemote.java | 20 +++++----- .../item/remote/ScreenNetworkRemote.java | 38 +++++++++---------- update.json | 3 +- 7 files changed, 41 insertions(+), 40 deletions(-) diff --git a/gradle.properties b/gradle.properties index 66e0a473..15292e9f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ org.gradle.daemon=false mod_id=storagenetwork curse_id=268495 -mod_version=1.11.2 +mod_version=1.11.3-SNAPSHOT diff --git a/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java b/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java index d6fbf3dc..c818226e 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java @@ -6,6 +6,7 @@ import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; +import com.lothrazar.storagenetwork.gui.TextboxInteger; import com.lothrazar.storagenetwork.jei.JeiHooks; import com.lothrazar.storagenetwork.network.SettingsSyncMessage; import com.lothrazar.storagenetwork.registry.PacketRegistry; @@ -131,7 +132,7 @@ public void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) int xCenter = (width - imageWidth) / 2; int yCenter = (height - imageHeight) / 2; ms.blit(texture, xCenter, yCenter, 0, 0, imageWidth, imageHeight); - //good stuff + network.applySearchTextToSlots(); network.renderItemSlots(ms, mouseX, mouseY, font); } @@ -176,13 +177,13 @@ public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { @Override public boolean keyPressed(int keyCode, int scanCode, int b) { InputConstants.Key mouseKey = InputConstants.getKey(keyCode, scanCode); - if (keyCode == 256) { + if (keyCode == TextboxInteger.KEY_ESC) { minecraft.player.closeContainer(); return true; // Forge MC-146650: Needs to return true when the key is handled. } if (network.searchBar.isFocused()) { network.searchBar.keyPressed(keyCode, scanCode, b); - if (keyCode == 259) { // BACKSPACE + if (keyCode == TextboxInteger.KEY_BACKSPACE) { // BACKSPACE network.syncTextToJei(); } return true; diff --git a/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java b/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java index 50971ea2..72ed8fca 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java @@ -6,6 +6,7 @@ import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; +import com.lothrazar.storagenetwork.gui.TextboxInteger; import com.lothrazar.storagenetwork.jei.JeiHooks; import com.lothrazar.storagenetwork.network.ClearRecipeMessage; import com.lothrazar.storagenetwork.network.RequestMessage; @@ -193,13 +194,13 @@ public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { @Override public boolean keyPressed(int keyCode, int scanCode, int b) { InputConstants.Key mouseKey = InputConstants.getKey(keyCode, scanCode); - if (keyCode == 256) { //ESCAPE + if (keyCode == TextboxInteger.KEY_ESC) { //ESCAPE minecraft.player.closeContainer(); return true; // Forge MC-146650: Needs to return true when the key is handled. } if (network.searchBar.isFocused()) { network.searchBar.keyPressed(keyCode, scanCode, b); - if (keyCode == 259) { // BACKSPACE + if (keyCode == TextboxInteger.KEY_BACKSPACE) { network.syncTextToJei(); } return true; @@ -215,6 +216,7 @@ else if (!network.stackUnderMouse.isEmpty()) { } //regardles of above branch, also check this if (minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { + minecraft.player.closeContainer(); return true; // Forge MC-146650: Needs to return true when the key is handled. } diff --git a/src/main/java/com/lothrazar/storagenetwork/gui/TextboxInteger.java b/src/main/java/com/lothrazar/storagenetwork/gui/TextboxInteger.java index bab6c8c1..9bc6a45d 100644 --- a/src/main/java/com/lothrazar/storagenetwork/gui/TextboxInteger.java +++ b/src/main/java/com/lothrazar/storagenetwork/gui/TextboxInteger.java @@ -12,8 +12,9 @@ */ public class TextboxInteger extends EditBox { - private static final int KEY_DELETE = 261; - private static final int KEY_BACKSPACE = 259; + public static final int KEY_ESC = 256; + public static final int KEY_DELETE = 261; + public static final int KEY_BACKSPACE = 259; public TextboxInteger(Font fontIn, int xIn, int yIn, int widthIn) { super(fontIn, xIn, yIn, widthIn, 16, null); diff --git a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java index fe688303..75367bf3 100644 --- a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java +++ b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java @@ -6,6 +6,7 @@ import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; +import com.lothrazar.storagenetwork.gui.TextboxInteger; import com.lothrazar.storagenetwork.jei.JeiHooks; import com.lothrazar.storagenetwork.network.ClearRecipeMessage; import com.lothrazar.storagenetwork.network.RequestMessage; @@ -23,11 +24,9 @@ public class ScreenNetworkCraftingRemote extends AbstractContainerScreen implements IGuiNetwork { - private static final int KEY_BACKSPACE = 259; - private static final int KEY_ESC = 256; private static final int HEIGHT = 256; private static final int WIDTH = 176; - private final ResourceLocation textureCraft = new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/request.png"); + private static final ResourceLocation textureCraft = new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/request.png"); private final NetworkWidget network; private final ItemStack remote; private int topOffset; @@ -139,12 +138,10 @@ public void render(GuiGraphics ms, int mouseX, int mouseY, float partialTicks) { @Override protected void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) { - // this.minecraft.getTextureManager().bind(textureCraft); - // RenderSystem.setShader(GameRenderer::getPositionTexShader); - // RenderSystem.setShaderTexture(0, textureCraft); - int k = (this.width - this.imageWidth) / 2; - int l = (this.height - this.imageHeight) / 2; - ms.blit(textureCraft, k, l, 0, 0, this.imageWidth, this.imageHeight); + + int xCenter = (this.width - this.imageWidth) / 2; + int yCenter = (this.height - this.imageHeight) / 2; + ms.blit(textureCraft, xCenter, yCenter, 0, 0, this.imageWidth, this.imageHeight); network.applySearchTextToSlots(); network.renderItemSlots(ms, mouseX, mouseY, font); } @@ -192,12 +189,12 @@ public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { @Override public boolean keyPressed(int keyCode, int scanCode, int b) { InputConstants.Key mouseKey = InputConstants.getKey(keyCode, scanCode); - if (keyCode == KEY_ESC) { + if (keyCode == TextboxInteger.KEY_ESC) { minecraft.player.closeContainer(); return true; // Forge MC-146650: Needs to return true when the key is handled. } if (network.searchBar.isFocused()) { - if (keyCode == KEY_BACKSPACE) { // BACKSPACE + if (keyCode == TextboxInteger.KEY_BACKSPACE) { // BACKSPACE network.syncTextToJei(); } network.searchBar.keyPressed(keyCode, scanCode, b); @@ -212,6 +209,7 @@ else if (!network.stackUnderMouse.isEmpty()) { } } //Regardless of above branch, also check this + if (minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { minecraft.player.closeContainer(); return true; // Forge MC-146650: Needs to return true when the key is handled. diff --git a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java index 501bbf39..aed449e0 100644 --- a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java +++ b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java @@ -6,6 +6,7 @@ import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; +import com.lothrazar.storagenetwork.gui.TextboxInteger; import com.lothrazar.storagenetwork.jei.JeiHooks; import com.lothrazar.storagenetwork.network.SettingsSyncMessage; import com.lothrazar.storagenetwork.registry.PacketRegistry; @@ -38,10 +39,14 @@ public ScreenNetworkRemote(ContainerNetworkRemote screenContainer, Inventory inv this.imageHeight = HEIGHT; } + @Override + public void drawGradient(GuiGraphics ms, int x, int y, int x2, int y2, int u, int v) { + ms.fillGradient(x, y, x2, y2, u, v); + } + @Override public void renderStackTooltip(GuiGraphics ms, ItemStack stack, int mousex, int mousey) { - // stack, - super.renderTooltip(ms, mousex, mousey); + ms.renderTooltip(font, stack, mousex, mousey); } @Override @@ -74,6 +79,11 @@ public void setSort(EnumSortType val) { ItemStorageCraftingRemote.setSort(remote, val); } + @Override + public boolean getAutoFocus() { + return ItemStorageCraftingRemote.getAutoFocus(remote); + } + @Override public void setAutoFocus(boolean b) { ItemStorageCraftingRemote.setAutoFocus(remote, b); @@ -126,12 +136,9 @@ public void render(GuiGraphics ms, int mouseX, int mouseY, float partialTicks) { @Override protected void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) { - // this.minecraft.getTextureManager().bind(texture); - // RenderSystem.setShader(GameRenderer::getPositionTexShader); - // RenderSystem.setShaderTexture(0, texture); - int k = (this.width - this.imageWidth) / 2; - int l = (this.height - this.imageHeight) / 2; - ms.blit(texture, k, l, 0, 0, this.imageWidth, this.imageHeight); + int xCenter = (this.width - this.imageWidth) / 2; + int yCenter = (this.height - this.imageHeight) / 2; + ms.blit(texture, xCenter, yCenter, 0, 0, this.imageWidth, this.imageHeight); network.applySearchTextToSlots(); network.renderItemSlots(ms, mouseX, mouseY, font); } @@ -169,12 +176,12 @@ public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { @Override public boolean keyPressed(int keyCode, int scanCode, int b) { InputConstants.Key mouseKey = InputConstants.getKey(keyCode, scanCode); - if (keyCode == 256) { + if (keyCode == TextboxInteger.KEY_ESC) { minecraft.player.closeContainer(); return true; // Forge MC-146650: Needs to return true when the key is handled. } if (network.searchBar.isFocused()) { - if (keyCode == 259) { // BACKSPACE + if (keyCode == TextboxInteger.KEY_BACKSPACE) { network.syncTextToJei(); } network.searchBar.keyPressed(keyCode, scanCode, b); @@ -190,6 +197,7 @@ else if (!network.stackUnderMouse.isEmpty()) { } //regardles of above branch, also check this if (minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { + minecraft.player.closeContainer(); return true; // Forge MC-146650: Needs to return true when the key is handled. } @@ -204,21 +212,11 @@ public boolean charTyped(char typedChar, int keyCode) { return false; } - @Override - public void drawGradient(GuiGraphics ms, int x, int y, int x2, int y2, int u, int v) { - ms.fillGradient(x, y, x2, y2, u, v); - } - @Override public boolean isInRegion(int x, int y, int width, int height, double mouseX, double mouseY) { return super.isHovering(x, y, width, height, mouseX, mouseY); } - @Override - public boolean getAutoFocus() { - return ItemStorageCraftingRemote.getAutoFocus(remote); - } - @Override public void syncDataToServer() { PacketRegistry.INSTANCE.sendToServer(new SettingsSyncMessage(null, getDownwards(), getSort(), this.isJeiSearchSynced(), this.getAutoFocus())); diff --git a/update.json b/update.json index 451c24a1..77e4d30a 100644 --- a/update.json +++ b/update.json @@ -1,7 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/simple-storage-network", "promos": { - "1.20.1-latest": "1.11.2" + "1.20.1-latest": "1.11.3" }, "1.20.1": { "1.10.0":"Ported to 1.20.1, depends on flib-0.0.7+ . Fixed patchouli book. Port to new non-deprecated curios datapack tags. Includes pull requests merged into the 1.18 and 1.19 branches : Merge pull request #492 from IIpragmaII/trunk/1.18 @IIpragmaII @VasurTrekkson Improved performance for export node. fix priority german translation @lightlike . Fixed recipes not showing when pressing the JEI recipe key @Demerso. Create uk_ua.json @SKZGx " @@ -11,5 +11,6 @@ ,"1.11.1":"The Storage Request Table 'storagenetwork:request' block no longer saves the contents of its crafting-grid; instead items are returned to the player on close, exactly matching vanilla crafting table behavior (this was changed to prevent potential exploits. If any items are left behind in the grid during world upgrade they will be returned and not lost. No changes were made to the remotes or to other blocks). Fixed a null pointer exception " ,"1.11.2":"Ported the Cable Facades feature (from Minecraft 1.12.2), so that you can shift-left-click with a block on a cable to hide it with a facade. Disable this feature or ignore certain blocks with the config file" + ,"1.11.3":"Fixed item tooltips not rendering in Storage Remote. " } }