diff --git a/src/main/java/com/lothrazar/storagenetwork/block/AbstractNetworkScreen.java b/src/main/java/com/lothrazar/storagenetwork/block/AbstractNetworkScreen.java index de297521..a5a642e0 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/AbstractNetworkScreen.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/AbstractNetworkScreen.java @@ -3,13 +3,9 @@ import java.util.List; import com.lothrazar.storagenetwork.StorageNetworkMod; import com.lothrazar.storagenetwork.api.IGuiNetwork; -import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.TileableTexture; import com.lothrazar.storagenetwork.gui.components.TextboxInteger; import com.lothrazar.storagenetwork.jei.JeiHooks; -import com.lothrazar.storagenetwork.network.ClearRecipeMessage; -import com.lothrazar.storagenetwork.network.RequestMessage; -import com.lothrazar.storagenetwork.registry.PacketRegistry; import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -99,23 +95,21 @@ public boolean mouseScrolled(double x, double y, double mouseButton) { public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { super.mouseClicked(mouseX, mouseY, mouseButton); getNetwork().mouseClicked(mouseX, mouseY, mouseButton); - var size = getNetwork().getSize(); - if (size.isCrafting()) { - //TODO: this is part of crafting grid, to clear it out. should be its own button class - int rectX = 63; - int rectY = 110; - if (size == NetworkScreenSize.EXPANDED) { - rectX = 63; - rectY = 110 + 200; - } - // TODO: revise above .out.println(mouseX + "," + mouseY); - if (isHovering(rectX, rectY, 7, 7, mouseX, mouseY)) { - - PacketRegistry.INSTANCE.sendToServer(new ClearRecipeMessage()); - PacketRegistry.INSTANCE.sendToServer(new RequestMessage(0, ItemStack.EMPTY, false, false)); - return true; - } - } + // var size = getNetwork().getSize(); + // if (size.isCrafting()) { + // //TODO: this is part of crafting grid, to clear it out. should be its own button class + // int rectX = 63; + // int rectY = 110; + // + // // TODO: revise above + // if (isHovering(rectX, rectY, 7, 7, mouseX, mouseY)) { + // System.out.println("clear cancelled do nothing,"); + // + // // PacketRegistry.INSTANCE.sendToServer(new ClearRecipeMessage()); + // // PacketRegistry.INSTANCE.sendToServer(new RequestMessage(0, ItemStack.EMPTY, false, false)); + // return true; + // } + // } return true; } diff --git a/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java b/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java index a0c5d3bb..134964f2 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java @@ -1,17 +1,12 @@ package com.lothrazar.storagenetwork.block.expand; -import com.lothrazar.storagenetwork.StorageNetworkMod; import com.lothrazar.storagenetwork.api.EnumSortType; import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import com.lothrazar.storagenetwork.gui.TileableTexture; -import com.lothrazar.storagenetwork.util.SsnConsts; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import net.minecraftforge.fml.ModList; @@ -38,6 +33,8 @@ public void init() { addRenderableWidget(network.directionBtn); addRenderableWidget(network.sortBtn); addRenderableWidget(network.focusBtn); + if (this.network.getSize().isCrafting()) + addRenderableWidget(network.clearGridBtn); if (this.getAutoFocus()) { network.searchBar.setFocused(true); } diff --git a/src/main/java/com/lothrazar/storagenetwork/block/expand/TileInventoryExpanded.java b/src/main/java/com/lothrazar/storagenetwork/block/expand/TileInventoryExpanded.java index 06b45cf0..e27ccbb8 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/expand/TileInventoryExpanded.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/expand/TileInventoryExpanded.java @@ -11,7 +11,7 @@ public class TileInventoryExpanded extends TileInventory { public TileInventoryExpanded(BlockPos pos, BlockState state) { - super(SsnRegistry.Tiles.INVENTORY_EXPANDED.get(), pos, state); + super(SsnRegistry.Tiles.REQUEST_EXPANDED.get(), pos, state); } @Override 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 69d56573..f45a83f0 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java @@ -5,7 +5,6 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -53,11 +52,6 @@ public void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) network.renderItemSlots(ms, mouseX, mouseY, font); } - @Override - public void resize(Minecraft mc, int w, int h) { - super.resize(mc, w, h); - network.resize(mc, w, h); - } // all the IGUINETWORK implementations @Override 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 15ba832e..8d90ddd5 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java @@ -5,7 +5,6 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -36,6 +35,8 @@ public void init() { addRenderableWidget(network.directionBtn); addRenderableWidget(network.sortBtn); addRenderableWidget(network.focusBtn); + if (this.network.getSize().isCrafting()) + addRenderableWidget(network.clearGridBtn); if (this.getAutoFocus()) { network.searchBar.setFocused(true); } @@ -54,11 +55,6 @@ public void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) network.renderItemSlots(ms, mouseX, mouseY, font); } - @Override - public void resize(Minecraft mc, int w, int h) { - super.resize(mc, w, h); - network.resize(mc, w, h); - } // all the IGUINETWORK implementations @Override @@ -81,6 +77,7 @@ public void setSort(EnumSortType s) { tile.setSort(s); } + @Override public BlockPos getPos() { return tile.getBlockPos(); } diff --git a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java index 93b99ebb..f00677a9 100644 --- a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java +++ b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java @@ -14,6 +14,7 @@ import com.lothrazar.storagenetwork.gui.components.ButtonRequest; import com.lothrazar.storagenetwork.gui.components.ButtonRequest.TextureEnum; import com.lothrazar.storagenetwork.gui.slot.ItemSlotNetwork; +import com.lothrazar.storagenetwork.network.ClearRecipeMessage; import com.lothrazar.storagenetwork.network.InsertMessage; import com.lothrazar.storagenetwork.network.RequestMessage; import com.lothrazar.storagenetwork.registry.PacketRegistry; @@ -46,6 +47,7 @@ public class NetworkWidget { public ButtonRequest sortBtn; public ButtonRequest jeiBtn; public ButtonRequest focusBtn; + public ButtonRequest clearGridBtn; private List slots; private final IGuiNetwork gui; private long lastClick; @@ -151,12 +153,23 @@ public void init(Font font) { }, DEFAULT_NARRATION); focusBtn.setHeight(11); focusBtn.setWidth(6); - } - - //called by outer component - @Deprecated - public void resize(Minecraft mc, int width, int height) { - //todo: how many rows? dynamically change size on screen resize from client + if (this.getSize() != NetworkScreenSize.LARGE) { + x = searchBar.getX() - 19; + y = searchBar.getY() + 13; + if (this.getSize() == NetworkScreenSize.EXPANDED) { + //omg this is a bit of a mess i should refactor this + x = searchBar.getX() - 99; + y = searchBar.getY() - 2; + } + clearGridBtn = new ButtonRequest( + x, y, "", (p) -> { + PacketRegistry.INSTANCE.sendToServer(new ClearRecipeMessage()); + PacketRegistry.INSTANCE.sendToServer(new RequestMessage(0, ItemStack.EMPTY, false, false)); + }, DEFAULT_NARRATION); + clearGridBtn.setHeight(7); + clearGridBtn.setWidth(7); + this.clearGridBtn.setTextureId(TextureEnum.CRAFTCLEAR); + } } public List getStacks() { @@ -331,6 +344,9 @@ public void drawGuiContainerForegroundLayer(GuiGraphics ms, int mouseX, int mous else if (sortBtn != null && sortBtn.isMouseOver(mouseX, mouseY)) { tooltip = Component.translatable("gui.storagenetwork.req.tooltip_" + gui.getSort().name().toLowerCase()); } + else if (clearGridBtn != null && clearGridBtn.isMouseOver(mouseX, mouseY)) { + tooltip = Component.translatable("gui.storagenetwork.req.tooltip_cleargrid"); + } else if (focusBtn != null && focusBtn.isMouseOver(mouseX, mouseY)) { tooltip = Component.translatable("gui.storagenetwork.autofocus.tooltip." + gui.getAutoFocus()); } @@ -459,6 +475,8 @@ public void render() { sortBtn.setTextureId(TextureEnum.SORT_NAME); break; } + if (this.clearGridBtn != null) { + } focusBtn.setTextureId(gui.getAutoFocus() ? TextureEnum.RED : TextureEnum.GREY); directionBtn.setTextureId(gui.getDownwards() ? TextureEnum.SORT_DOWN : TextureEnum.SORT_UP); if (jeiBtn != null && ModList.get().isLoaded("jei")) { diff --git a/src/main/java/com/lothrazar/storagenetwork/gui/components/ButtonRequest.java b/src/main/java/com/lothrazar/storagenetwork/gui/components/ButtonRequest.java index 8dc90f33..9ddc01ba 100644 --- a/src/main/java/com/lothrazar/storagenetwork/gui/components/ButtonRequest.java +++ b/src/main/java/com/lothrazar/storagenetwork/gui/components/ButtonRequest.java @@ -14,7 +14,7 @@ public class ButtonRequest extends Button { public static enum TextureEnum { - ALLOWLIST, IGNORELIST, SORT_AMT, SORT_MOD, SORT_NAME, SORT_UP, SORT_DOWN, JEI_RED, JEI_GREEN, IMPORT, PLUS, MINUS, REDSTONETRUE, REDSTONEFALSE, RED, GREY; + ALLOWLIST, IGNORELIST, SORT_AMT, SORT_MOD, SORT_NAME, SORT_UP, SORT_DOWN, JEI_RED, JEI_GREEN, IMPORT, PLUS, MINUS, REDSTONETRUE, REDSTONEFALSE, RED, GREY, CRAFTCLEAR; public int getX() { switch (this) { @@ -50,6 +50,8 @@ public int getX() { return 196; case MINUS: return 177; + case CRAFTCLEAR: + return 209; default: return 0; } @@ -82,6 +84,8 @@ public int getY() { return 13; case MINUS: return 13; + case CRAFTCLEAR: + return 53; default: return 0; } 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 acbc3a58..c66461e4 100644 --- a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java +++ b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java @@ -5,7 +5,6 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -37,6 +36,8 @@ public void init() { addRenderableWidget(network.directionBtn); addRenderableWidget(network.sortBtn); addRenderableWidget(network.focusBtn); + if (this.network.getSize().isCrafting()) + addRenderableWidget(network.clearGridBtn); if (this.getAutoFocus()) { network.searchBar.setFocused(true); } diff --git a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkExpandedRemote.java b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkExpandedRemote.java index a355f39a..44576004 100644 --- a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkExpandedRemote.java +++ b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkExpandedRemote.java @@ -1,14 +1,11 @@ package com.lothrazar.storagenetwork.item.remote; -import com.lothrazar.storagenetwork.StorageNetworkMod; import com.lothrazar.storagenetwork.api.EnumSortType; import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; import net.minecraftforge.fml.ModList; @@ -36,6 +33,8 @@ public void init() { addRenderableWidget(network.directionBtn); addRenderableWidget(network.sortBtn); addRenderableWidget(network.focusBtn); + if (network.clearGridBtn != null) + addRenderableWidget(network.clearGridBtn); if (this.getAutoFocus()) { network.searchBar.setFocused(true); } 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 b1f76eba..2bbe88d6 100644 --- a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java +++ b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java @@ -5,7 +5,6 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -55,12 +54,6 @@ protected void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mous network.renderItemSlots(ms, mouseX, mouseY, font); } - @Override - public void resize(Minecraft mc, int w, int h) { - super.resize(mc, w, h); - network.resize(mc, w, h); - } - @Override public boolean getDownwards() { return ItemStorageCraftingRemote.getDownwards(remote); diff --git a/src/main/java/com/lothrazar/storagenetwork/registry/SsnRegistry.java b/src/main/java/com/lothrazar/storagenetwork/registry/SsnRegistry.java index d38728f9..b856080c 100644 --- a/src/main/java/com/lothrazar/storagenetwork/registry/SsnRegistry.java +++ b/src/main/java/com/lothrazar/storagenetwork/registry/SsnRegistry.java @@ -71,7 +71,7 @@ public static class Blocks { public static final RegistryObject FILTER_KABEL = BLOCKS.register("filter_kabel", () -> new BlockCableFilter()); public static final RegistryObject EXPORT_KABEL = BLOCKS.register("export_kabel", () -> new BlockCableExport()); public static final RegistryObject INVENTORY = BLOCKS.register("inventory", () -> new BlockInventory()); - public static final RegistryObject INVENTORY_EXPANDED = BLOCKS.register("inventory_expanded", () -> new BlockInventoryExpanded()); + public static final RegistryObject REQUEST_EXPANDED = BLOCKS.register("request_expanded", () -> new BlockInventoryExpanded()); public static final RegistryObject EXCHANGE = BLOCKS.register("exchange", () -> new BlockExchange()); public static final RegistryObject COLLECTOR = BLOCKS.register("collector", () -> new BlockCollection()); } @@ -83,7 +83,7 @@ public static class Items { // public static final RegistryObject REQUEST_EXPANDED = ITEMS.register("request_expanded", () -> new BlockItem(Blocks.REQUEST_EXPANDED.get(), new Item.Properties())); public static final RegistryObject KABEL = ITEMS.register("kabel", () -> new BlockItem(Blocks.KABEL.get(), new Item.Properties())); public static final RegistryObject INVENTORY = ITEMS.register("inventory", () -> new BlockItem(Blocks.INVENTORY.get(), new Item.Properties())); - public static final RegistryObject INVENTORY_EXPANDED = ITEMS.register("inventory_expanded", () -> new BlockItem(Blocks.INVENTORY_EXPANDED.get(), new Item.Properties())); + public static final RegistryObject INVENTORY_EXPANDED = ITEMS.register("request_expanded", () -> new BlockItem(Blocks.REQUEST_EXPANDED.get(), new Item.Properties())); public static final RegistryObject MAS = ITEMS.register("master", () -> new BlockItem(Blocks.MASTER.get(), new Item.Properties())); public static final RegistryObject SK = ITEMS.register("storage_kabel", () -> new BlockItem(Blocks.STORAGE_KABEL.get(), new Item.Properties())); public static final RegistryObject IK = ITEMS.register("import_kabel", () -> new BlockItem(Blocks.IMPORT_KABEL.get(), new Item.Properties())); @@ -111,7 +111,7 @@ public static class Tiles { public static final RegistryObject> MASTER = TILES.register("master", () -> BlockEntityType.Builder.of(TileMain::new, Blocks.MASTER.get()).build(null)); public static final RegistryObject> INVENTORY = TILES.register("inventory", () -> BlockEntityType.Builder.of(TileInventory::new, Blocks.INVENTORY.get()).build(null)); - public static final RegistryObject> INVENTORY_EXPANDED = TILES.register("inventory_expanded", () -> BlockEntityType.Builder.of(TileInventoryExpanded::new, Blocks.INVENTORY_EXPANDED.get()).build(null)); + public static final RegistryObject> REQUEST_EXPANDED = TILES.register("request_expanded", () -> BlockEntityType.Builder.of(TileInventoryExpanded::new, Blocks.REQUEST_EXPANDED.get()).build(null)); public static final RegistryObject> REQUEST = TILES.register("request", () -> BlockEntityType.Builder.of(TileRequest::new, Blocks.REQUEST.get()).build(null)); public static final RegistryObject> KABEL = TILES.register("kabel", () -> BlockEntityType.Builder.of(TileCable::new, Blocks.KABEL.get()).build(null)); public static final RegistryObject> STORAGE_KABEL = TILES.register("storage_kabel", () -> BlockEntityType.Builder.of(TileCableLink::new, Blocks.STORAGE_KABEL.get()).build(null)); diff --git a/src/main/resources/assets/storagenetwork/blockstates/request_expanded.json b/src/main/resources/assets/storagenetwork/blockstates/request_expanded.json new file mode 100644 index 00000000..95bc2035 --- /dev/null +++ b/src/main/resources/assets/storagenetwork/blockstates/request_expanded.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "storagenetwork:block/request_expanded" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/storagenetwork/lang/en_us.json b/src/main/resources/assets/storagenetwork/lang/en_us.json index 76df02ea..70c00d7a 100644 --- a/src/main/resources/assets/storagenetwork/lang/en_us.json +++ b/src/main/resources/assets/storagenetwork/lang/en_us.json @@ -150,6 +150,8 @@ "gui.storagenetwork.tooltip_clear": "Clear Search", "gui.storagenetwork.fil.tooltip_jei_on": "JEI search enabled", "gui.storagenetwork.fil.tooltip_jei_off": "JEI search disabled", + + "gui.storagenetwork.req.tooltip_cleargrid":"Clear Grid", "block.storagenetwork.kabel.tooltip": "Basic network cable ", "block.storagenetwork.storage_kabel.tooltip": "Used to connect inventory to the network", diff --git a/src/main/resources/assets/storagenetwork/models/block/request_expanded.json b/src/main/resources/assets/storagenetwork/models/block/request_expanded.json new file mode 100644 index 00000000..7af132ec --- /dev/null +++ b/src/main/resources/assets/storagenetwork/models/block/request_expanded.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "storagenetwork:block/request_expanded" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/storagenetwork/models/item/expanded_remote.json b/src/main/resources/assets/storagenetwork/models/item/expanded_remote.json new file mode 100644 index 00000000..22d8076c --- /dev/null +++ b/src/main/resources/assets/storagenetwork/models/item/expanded_remote.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "storagenetwork:item/expanded_remote" + } +} diff --git a/src/main/resources/assets/storagenetwork/textures/gui/cable.png b/src/main/resources/assets/storagenetwork/textures/gui/cable.png index 15ec9e93..56d4eea8 100755 Binary files a/src/main/resources/assets/storagenetwork/textures/gui/cable.png and b/src/main/resources/assets/storagenetwork/textures/gui/cable.png differ diff --git a/src/main/resources/assets/storagenetwork/textures/gui/expandable_crafting.png b/src/main/resources/assets/storagenetwork/textures/gui/expandable_crafting.png index 35a74a03..3bd7c4f2 100644 Binary files a/src/main/resources/assets/storagenetwork/textures/gui/expandable_crafting.png and b/src/main/resources/assets/storagenetwork/textures/gui/expandable_crafting.png differ diff --git a/src/main/resources/assets/storagenetwork/textures/gui/request.png b/src/main/resources/assets/storagenetwork/textures/gui/request.png index dfdf01f5..3c0022d9 100755 Binary files a/src/main/resources/assets/storagenetwork/textures/gui/request.png and b/src/main/resources/assets/storagenetwork/textures/gui/request.png differ