diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md deleted file mode 100644 index 210d27f7..00000000 --- a/.github/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,31 +0,0 @@ -Code of Merit ( https://github.com/rosarior/Code-of-Merit ) - -The project creators, lead developers, core team, constitute the managing members of the project and have final say in every decision of the project, technical or otherwise, including overruling previous decisions. There are no limitations to this decisional power. - -Contributions are an expected result of your membership on the project. Don't expect others to do your work or help you with your work forever. - -All members have the same opportunities to seek any challenge they want within the project. - -Authority or position in the project will be proportional to the accrued contribution. Seniority must be earned. - -Software is evolutive: the better implementations must supersede lesser implementations. Technical advantage is the primary evaluation metric. - -This is a space for technical prowess; topics outside of the project will not be tolerated. - -Non technical conflicts will be discussed in a separate space. Disruption of the project will not be allowed. - -Individual characteristics, including but not limited to, body, sex, sexual preference, race, language, religion, nationality, or political preferences are irrelevant in the scope of the project and will not be taken into account concerning your value or that of your contribution to the project. - -Discuss or debate the idea, not the person. - -There is no room for ambiguity: Ambiguity will be met with questioning; further ambiguity will be met with silence. It is the responsibility of the originator to provide requested context. - -If something is illegal outside the scope of the project, it is illegal in the scope of the project. This Code of Merit does not take precedence over governing law. - -This Code of Merit governs the technical procedures of the project not the activities outside of it. - -Participation on the project equates to agreement of this Code of Merit. - -No objectives beyond the stated objectives of this project are relevant to the project. Any intent to deviate the project from its original purpose of existence will constitute grounds for remedial action which may include expulsion from the project. - -This document is the Code of Merit (http://code-of-merit.org), version 1.0. diff --git a/build.gradle b/build.gradle index 2153fced..4fb9b42d 100755 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,8 @@ minecraft { property 'forge.logging.console.level', 'debug' properties 'mixin.env.disableRefMap': 'true' + args '--username=ADev' + mods { storagenetwork { source sourceSets.main diff --git a/gradle.properties b/gradle.properties index 08be8c60..ac618f37 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,12 +2,17 @@ # 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") + curse_id=268495 -mod_version=1.7.0 +mod_version=1.7.1 # optional dependencies diff --git a/src/main/java/com/lothrazar/storagenetwork/block/request/BlockRequest.java b/src/main/java/com/lothrazar/storagenetwork/block/request/BlockRequest.java index 2d8d980f..4f2e7032 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/request/BlockRequest.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/request/BlockRequest.java @@ -11,7 +11,6 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.RenderShape; @@ -48,15 +47,6 @@ public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState n Containers.dropContents(worldIn, pos, (Container) blockentity); worldIn.updateNeighbourForOutputSignal(pos, this); } - BlockEntity tileentity = worldIn.getBlockEntity(pos); - if (tileentity instanceof TileRequest) { - TileRequest tile = (TileRequest) tileentity; - for (ItemStack entry : tile.matrix.values()) { - if (!entry.isEmpty()) { - Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entry); - } - } - } super.onRemove(state, worldIn, pos, newState, isMoving); } } diff --git a/src/main/java/com/lothrazar/storagenetwork/block/request/ContainerNetworkCraftingTable.java b/src/main/java/com/lothrazar/storagenetwork/block/request/ContainerNetworkCraftingTable.java index 72543577..837c9bb5 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/request/ContainerNetworkCraftingTable.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/request/ContainerNetworkCraftingTable.java @@ -7,16 +7,19 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.ContainerLevelAccess; import net.minecraft.world.level.Level; public class ContainerNetworkCraftingTable extends ContainerNetwork { private final TileRequest tileRequest; + private final ContainerLevelAccess access; public ContainerNetworkCraftingTable(int windowId, Level world, BlockPos pos, Inventory playerInv, Player player) { super(SsnRegistry.Menus.REQUEST.get(), windowId); tileRequest = (TileRequest) world.getBlockEntity(pos); - matrix = new NetworkCraftingInventory(this, tileRequest.matrix); + matrix = new NetworkCraftingInventory(this); + access = ContainerLevelAccess.create(world, pos); this.playerInv = playerInv; SlotCraftingNetwork slotCraftOutput = new SlotCraftingNetwork(this, playerInv.player, matrix, resultInventory, 0, 101, 128); slotCraftOutput.setTileMain(getTileMain()); @@ -32,18 +35,22 @@ public boolean isCrafting() { return true; } + @Override + public void removed(Player player) { + super.removed(player); + //the contents of the crafting matrix gets returned to the player + this.access.execute((level, pos) -> { + 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/TileRequest.java b/src/main/java/com/lothrazar/storagenetwork/block/request/TileRequest.java index 6f96b922..2772288b 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/request/TileRequest.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/request/TileRequest.java @@ -7,6 +7,7 @@ import com.lothrazar.storagenetwork.api.ITileNetworkSync; import com.lothrazar.storagenetwork.block.TileConnectable; import com.lothrazar.storagenetwork.registry.SsnRegistry; +import com.lothrazar.storagenetwork.util.UtilInventory; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -24,11 +25,12 @@ public class TileRequest extends TileConnectable implements MenuProvider, ITileN public static final String NBT_JEI = StorageNetworkMod.MODID + "jei"; private static final String NBT_DIR = StorageNetworkMod.MODID + "dir"; private static final String NBT_SORT = StorageNetworkMod.MODID + "sort"; - public Map 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 9f949339..72b47c38 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; @@ -16,25 +15,14 @@ public class NetworkCraftingInventory extends CraftingContainer { 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, 3, 3); eventHandler = eventHandlerIn; stackList = NonNullList. withSize(3 * 3, ItemStack.EMPTY); } public NetworkCraftingInventory(AbstractContainerMenu eventHandlerIn, Map matrix) { - this(eventHandlerIn, 3, 3); - 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); + this(eventHandlerIn); skipEvents = true; for (int i = 0; i < 9; i++) { if (matrix.get(i) != null && matrix.get(i).isEmpty() == false) { diff --git a/src/main/java/com/lothrazar/storagenetwork/util/UtilConnections.java b/src/main/java/com/lothrazar/storagenetwork/util/UtilConnections.java index eac793b5..f78ecbc1 100644 --- a/src/main/java/com/lothrazar/storagenetwork/util/UtilConnections.java +++ b/src/main/java/com/lothrazar/storagenetwork/util/UtilConnections.java @@ -8,7 +8,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.registries.ForgeRegistries; public class UtilConnections { @@ -48,7 +48,7 @@ public static boolean isInventory(Direction facing, LevelAccessor world, BlockPo } BlockEntity neighbor = world.getBlockEntity(facingPos); if (neighbor != null - && neighbor.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null) != null) { + && neighbor.getCapability(ForgeCapabilities.ITEM_HANDLER, facing.getOpposite()).orElse(null) != null) { return true; } return false; diff --git a/update.json b/update.json index adc10d85..03f6df63 100644 --- a/update.json +++ b/update.json @@ -2,12 +2,13 @@ "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.2-latest": "1.7.1" }, "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.7.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) " } }