Skip to content

Commit

Permalink
fix item tooltips in remote not rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Oct 13, 2024
1 parent c279901 commit 8d46526
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 40 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,11 +24,9 @@

public class ScreenNetworkCraftingRemote extends AbstractContainerScreen<ContainerNetworkCraftingRemote> 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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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.
}
Expand All @@ -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()));
Expand Down
3 changes: 2 additions & 1 deletion update.json
Original file line number Diff line number Diff line change
@@ -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 "
Expand All @@ -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. "
}
}

0 comments on commit 8d46526

Please sign in to comment.