diff --git a/build.gradle b/build.gradle index 1d1cfd6d..f8251051 100755 --- a/build.gradle +++ b/build.gradle @@ -74,6 +74,7 @@ minecraft { // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' + mods { "${mod_id}" { source sourceSets.main @@ -86,6 +87,7 @@ minecraft { property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id + args '--username=ADev' } server { diff --git a/gradle.properties b/gradle.properties index f3468457..51cc9c6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,18 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx6G org.gradle.daemon=false -# org.gradle.java.home=C:\Program Files\AdoptOpenJDK\jdk-16.0.1.9-hotspot + + +#use this if the gradle build has ' Could not find tools.jar. Please check that _____ contains a valid JDK installation ' +#org.gradle.java.home=C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot + # as needed run/server.properties : online-mode=false # implementation fg.deobf("curse.maven:simple-storage-network-268495:3163007") mod_id=storagenetwork curse_id=268495 -mod_version=1.11.0 +mod_version=1.11.1 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 eed5be12..d6fbf3dc 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java @@ -5,10 +5,8 @@ import com.lothrazar.storagenetwork.api.EnumSortType; import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize; +import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; import com.lothrazar.storagenetwork.jei.JeiHooks; -import com.lothrazar.storagenetwork.network.ClearRecipeMessage; -import com.lothrazar.storagenetwork.network.RequestMessage; import com.lothrazar.storagenetwork.network.SettingsSyncMessage; import com.lothrazar.storagenetwork.registry.PacketRegistry; import com.mojang.blaze3d.platform.InputConstants; @@ -39,7 +37,7 @@ public class ScreenNetworkInventory extends AbstractContainerScreen { + this.clearContainer(player, this.matrix); + }); + } + @Override public void slotChanged() { //parent is abstract - //seems to not happen from -shiftclick- crafting - for (int i = 0; i < matrix.getContainerSize(); i++) { - getTileRequest().matrix.put(i, matrix.getItem(i)); - } } @Override public boolean stillValid(Player playerIn) { - // TileMain main = getTileMain(); TileRequest table = getTileRequest(); BlockPos pos = table.getBlockPos(); return playerIn.distanceToSqr(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D; 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 6db421ec..50971ea2 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,7 @@ import com.lothrazar.storagenetwork.api.EnumSortType; import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize; +import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; import com.lothrazar.storagenetwork.jei.JeiHooks; import com.lothrazar.storagenetwork.network.ClearRecipeMessage; import com.lothrazar.storagenetwork.network.RequestMessage; @@ -37,7 +37,7 @@ public class ScreenNetworkTable extends AbstractContainerScreen matrix = new HashMap<>(); private boolean downwards; private EnumSortType sort = EnumSortType.NAME; private boolean isJeiSearchSynced; private boolean autoFocus = true; + @Deprecated + private Map matrix = new HashMap<>(); public TileRequest(BlockPos pos, BlockState state) { super(SsnRegistry.Tiles.REQUEST.get(), pos, state); @@ -44,13 +46,25 @@ public void load(CompoundTag compound) { if (compound.contains(NBT_JEI)) { this.setJeiSearchSynced(compound.getBoolean(NBT_JEI)); } - ListTag invList = compound.getList("matrix", Tag.TAG_COMPOUND); - matrix = new HashMap<>(); - for (int i = 0; i < invList.size(); i++) { - CompoundTag stackTag = invList.getCompound(i); - int slot = stackTag.getByte("Slot"); - ItemStack s = ItemStack.of(stackTag); - matrix.put(slot, s); + //legacy support: instead of deleting items, in this one-off world upgrade transition + //drop them on the ground + //then forever more it will not be saved to this data location + if (compound.contains("matrix")) { + ListTag invList = compound.getList("matrix", Tag.TAG_COMPOUND); + for (int i = 0; i < invList.size(); i++) { + CompoundTag stackTag = invList.getCompound(i); + int slot = stackTag.getByte("Slot"); + ItemStack s = ItemStack.of(stackTag); + if (level != null) { + StorageNetworkMod.LOGGER.info("world upgrade: item dropping onluy once so it doesnt get deleted; " + this.worldPosition + ":" + s); + UtilInventory.dropItem(level, this.worldPosition, s); + matrix.put(slot, ItemStack.EMPTY); + } + else { + //i was not able to drop it in the world. save it so its not deleted. will be hidden from player + matrix.put(slot, s); + } + } } super.load(compound); } @@ -61,16 +75,26 @@ public void saveAdditional(CompoundTag compound) { compound.putBoolean(NBT_DIR, isDownwards()); compound.putInt(NBT_SORT, getSort().ordinal()); compound.putBoolean(NBT_JEI, this.isJeiSearchSynced()); - ListTag invList = new ListTag(); - for (int i = 0; i < 9; i++) { - if (matrix.get(i) != null && matrix.get(i).isEmpty() == false) { - CompoundTag stackTag = new CompoundTag(); - stackTag.putByte("Slot", (byte) i); - matrix.get(i).save(stackTag); - invList.add(stackTag); + if (matrix != null) { + ListTag invList = new ListTag(); + for (int i = 0; i < 9; i++) { + if (matrix.get(i) != null && matrix.get(i).isEmpty() == false) { + if (level != null) { + StorageNetworkMod.LOGGER.info("World Upgrade: item dropping only once so it doesnt get deleted; " + this.worldPosition + ":" + matrix.get(i)); + UtilInventory.dropItem(level, this.worldPosition, matrix.get(i)); + matrix.put(i, ItemStack.EMPTY); + } + else { + //i was not able to drop it in the world. keep saving it and never delete items. will be hidden from player + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) i); + matrix.get(i).save(stackTag); + invList.add(stackTag); + } + } } + compound.put("matrix", invList); } - compound.put("matrix", invList); } @Override diff --git a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkCraftingInventory.java b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkCraftingInventory.java index 48d6a2af..bf585160 100644 --- a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkCraftingInventory.java +++ b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkCraftingInventory.java @@ -1,6 +1,5 @@ package com.lothrazar.storagenetwork.gui; -import java.util.List; import java.util.Map; import net.minecraft.core.NonNullList; import net.minecraft.world.ContainerHelper; @@ -11,32 +10,22 @@ public class NetworkCraftingInventory extends TransientCraftingContainer { + private static final int SIZE = 3; /** stupid thing is private with no getter so overwrite */ private final NonNullList stackList; private final AbstractContainerMenu eventHandler; private boolean skipEvents; - private NetworkCraftingInventory(AbstractContainerMenu eventHandlerIn, int width, int height) { - super(eventHandlerIn, width, height); + public NetworkCraftingInventory(AbstractContainerMenu eventHandlerIn) { + super(eventHandlerIn, SIZE, SIZE); eventHandler = eventHandlerIn; - stackList = NonNullList. withSize(3 * 3, ItemStack.EMPTY); + stackList = NonNullList. withSize(SIZE * SIZE, ItemStack.EMPTY); } public NetworkCraftingInventory(AbstractContainerMenu eventHandlerIn, Map matrix) { - this(eventHandlerIn, 3, 3); + this(eventHandlerIn); skipEvents = true; - for (int i = 0; i < 9; i++) { - if (matrix.get(i) != null && matrix.get(i).isEmpty() == false) { - setItem(i, matrix.get(i)); - } - } - skipEvents = false; - } - - public NetworkCraftingInventory(AbstractContainerMenu eventHandlerIn, List matrix) { - this(eventHandlerIn, 3, 3); - skipEvents = true; - for (int i = 0; i < 9; i++) { + for (int i = 0; i < SIZE * SIZE; i++) { if (matrix.get(i) != null && matrix.get(i).isEmpty() == false) { setItem(i, matrix.get(i)); } diff --git a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java index df175b82..b177759b 100644 --- a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java +++ b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java @@ -55,9 +55,10 @@ public class NetworkWidget { @Deprecated public NetworkWidget(IGuiNetwork gui) { - this(gui, NetworkGuiSize.NORMAL); + this(gui, NetworkScreenSize.NORMAL); } - public NetworkWidget(IGuiNetwork gui, NetworkGuiSize size) { + + public NetworkWidget(IGuiNetwork gui, NetworkScreenSize size) { this.gui = gui; switch (size) { case LARGE: @@ -73,6 +74,16 @@ public NetworkWidget(IGuiNetwork gui, NetworkGuiSize size) { slots = Lists.newArrayList(); PacketRegistry.INSTANCE.sendToServer(new RequestMessage()); lastClick = System.currentTimeMillis(); + switch (size) { + case LARGE: + setLines(8); + setFieldHeight(180 - 8); // offset is important + break; + case NORMAL: + setLines(4); + setFieldHeight(90); + break; + } } public List getStacks() { @@ -185,7 +196,6 @@ public void rebuildItemSlots(List stacksToDisplay) { break; } int in = index; - slots.add(new ItemSlotNetwork(gui, stacksToDisplay.get(in), gui.getGuiLeft() + 8 + col * 18, gui.getGuiTopFixJei() + 10 + row * 18, @@ -419,7 +429,7 @@ public interface ISearchHandler { public abstract String getName(); } - public enum NetworkGuiSize { + public enum NetworkScreenSize { NORMAL, LARGE; } } 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 7606f15e..fe688303 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,7 @@ import com.lothrazar.storagenetwork.api.EnumSortType; import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize; +import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; import com.lothrazar.storagenetwork.jei.JeiHooks; import com.lothrazar.storagenetwork.network.ClearRecipeMessage; import com.lothrazar.storagenetwork.network.RequestMessage; @@ -36,8 +36,7 @@ public ScreenNetworkCraftingRemote(ContainerNetworkCraftingRemote screenContaine super(screenContainer, inv, titleIn); //since the rightclick action forces only MAIN_HAND openings, is ok this.remote = screenContainer.getRemote();// inv.player.getItemInHand(InteractionHand.MAIN_HAND); - network = new NetworkWidget(this, NetworkGuiSize.NORMAL); - + network = new NetworkWidget(this, NetworkScreenSize.NORMAL); this.imageWidth = WIDTH; this.imageHeight = HEIGHT; } 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 d045d790..501bbf39 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,7 @@ import com.lothrazar.storagenetwork.api.EnumSortType; import com.lothrazar.storagenetwork.api.IGuiNetwork; import com.lothrazar.storagenetwork.gui.NetworkWidget; -import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize; +import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkScreenSize; import com.lothrazar.storagenetwork.jei.JeiHooks; import com.lothrazar.storagenetwork.network.SettingsSyncMessage; import com.lothrazar.storagenetwork.registry.PacketRegistry; @@ -32,8 +32,8 @@ public class ScreenNetworkRemote extends AbstractContainerScreen * Used by Containers displaying network inventory as well as most other packets that perform small actions */ +@SuppressWarnings("resource") public class RefreshFilterClientMessage { private int size; diff --git a/update.json b/update.json index 1122c653..9b42f817 100644 --- a/update.json +++ b/update.json @@ -1,27 +1,14 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/simple-storage-network", "promos": { - "1.18.2-latest": "1.7.0", - "1.19.2-latest": "1.7.0", - "1.19.3-latest": "1.8.0", - "1.19.4-latest": "1.9.0", - "1.20.1-latest": "1.11.0" - }, - "1.19.2": { - "1.7.0":"Merged 1.18.2-1.7.0. Compatible with jei==11.4+, forge=43+. Community Pull Request Contributions: 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 . " - - }, - "1.19.3": { - "1.8.0":"Merged 1.18.2-1.7.0. Compatible with jei==11.4+, forge=43+. Community Pull Request Contributions: 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 . " - - }, - "1.19.4": { - "1.9.0":"Ported to 1.19.4. Previous changelog: Community Pull Request Contributions: 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 . " - + "1.20.1-latest": "1.11.1" }, "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 " ,"1.10.1":" Merge pull request #518 from ALFEECLARE: add ja_jp translation." ,"1.11.0":" Fix the bug when using small window sizes where the top row of player inventory items getting inserted instead of picked up when using the remote when jei is installed. Merge pull request #536 from maxpowa : Add support for EMI mod; this also fixes crash #513. " + + ,"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 " + } }