From 836f4fc156f21344879413e855daa6c652a295ce Mon Sep 17 00:00:00 2001 From: zyxkad Date: Mon, 17 Mar 2025 14:42:15 -0600 Subject: [PATCH 1/5] update gradle.properties --- gradle.properties | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/gradle.properties b/gradle.properties index f4735631c..93e3534e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -org.gradle.jvmargs=-Xmx4G org.gradle.daemon=false +org.gradle.jvmargs=-Xmx4G org.gradle.logging.level=info # Minecraft related @@ -10,53 +10,57 @@ mod_id=advancedperipherals mod_version=0.8r minecraft_version=1.19.2 mod_artifact_suffix= + forge_version=43.4.0 loader_version=43 + release_type=release + mappings_channel=parchment mappings_version=2022.11.20-1.19.2 -jb_annotations=21.0.1 # Test dependencies -junit_version=5.7.2 hamcrest_version=2.2 +jb_annotations=21.0.1 +junit_version=5.7.2 kotlin_version=1.8.0 kotlinx_coroutines_version=1.7.3 ttoolkit_version=0.1.3 # Mod dependencies cc_version=1.101.3 -curios_version=1.19.2-5.1.4.1 -minecolonies_version=1.19.2-1.1.473-BETA -appliedenergistics_version=12.9.9 -patchouli_version=1.19.2-77 -refinedstorage_version=1.11.7 + +ae2additions_version=4646599 +ae2things_version=4367610 +appliedenergistics_version=12.9.12 +appliedmekanistics_version=4734608 botania_version=1.19.2-440-FORGE +clockwork_version=5171528 create_version=0.5.1.f-46 createca_version=5099757 +curios_version=1.19.2-5.1.4.1 +dimstorage_version=3927875 +eureka_ships_version=5321628 +kotlinforforge_version=3.12.0 mekanism_version=1.19.2-10.3.9.13 -ae2things_version=4367610 +minecolonies_version=1.19.2-1.1.473-BETA +patchouli_version=1.19.2-77 powah_version=4183078 -ae2additions_version=4646599 -kotlinforforge_version=3.12.0 -appliedmekanistics_version=4734608 -dimstorage_version=3927875 +refinedstorage_version=1.11.7 valkyrien_skies_version=4994898 -eureka_ships_version=5321628 -clockwork_version=5171528 vs2_version=2.1.2-beta.1+a04911c932 vs_core_version=1.1.0+2a62e6a823 # Mod dependencies which are needed for other mods # For minecolonies -structurize_version=1.19.2-1.0.649-BETA -multipiston_version=1.19.2-1.2.21-ALPHA blockui_version=1.19.2-0.0.102-ALPHA domumornamentum_version=1.19-1.0.141-BETA +multipiston_version=1.19.2-1.2.21-ALPHA +structurize_version=1.19.2-1.0.649-BETA # For DimStorage edivadlib_version=3927847 -# Mod dependencies for testing stuff(Only used in the dev environment) +# Mod dependencies for testing stuff (Only used in the dev environment) +jade_version=4914105 jei_version=1.19.2-forge:11.6.0.1016 -jade_version=4914105 \ No newline at end of file From 2404887725ebb9aaf41f1edd89ea8a2213de46ca Mon Sep 17 00:00:00 2001 From: zyxkad Date: Mon, 17 Mar 2025 14:49:33 -0600 Subject: [PATCH 2/5] implement ICapabilityProvider on MeBridgePeripheral close IntelligenceModding/Advanced-Peripherals-Features#77 --- .../peripheral/MeBridgePeripheral.java | 48 +++++++++++++++---- .../common/util/inventory/InventoryUtil.java | 5 ++ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java index 4eb0b169d..34be8f3fe 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java @@ -33,6 +33,10 @@ import de.srendi.advancedperipherals.common.util.inventory.ItemFilter; import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; import net.minecraft.core.Direction; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandler; import org.jetbrains.annotations.NotNull; @@ -50,6 +54,7 @@ public class MeBridgePeripheral extends BasePeripheral filter = ItemFilter.parse(arguments.getTable(0)); if (filter.rightPresent()) @@ -100,8 +117,7 @@ protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable II * @return the exportable amount or null with a string if something went wrong */ protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFluidHandler targetTank) throws LuaException { - MEStorage monitor = AppEngApi.getMonitor(node); - MeFluidHandler fluidHandler = new MeFluidHandler(monitor, bridge); + MeFluidHandler fluidHandler = getFluidHandler(); Pair filter = FluidFilter.parse(arguments.getTable(0)); if (filter.rightPresent()) @@ -121,8 +137,7 @@ protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFl * @return the imported amount or null with a string if something went wrong */ protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { - MEStorage monitor = AppEngApi.getMonitor(node); - MeItemHandler itemHandler = new MeItemHandler(monitor, bridge); + MeItemHandler itemHandler = getItemHandler(); Pair filter = ItemFilter.parse(arguments.getTable(0)); if (filter.rightPresent()) @@ -142,8 +157,7 @@ protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IItem * @return the imported amount or null with a string if something went wrong */ protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IFluidHandler targetTank) throws LuaException { - MEStorage monitor = AppEngApi.getMonitor(node); - MeFluidHandler fluidHandler = new MeFluidHandler(monitor, bridge); + MeFluidHandler fluidHandler = getFluidHandler(); Pair filter = FluidFilter.parse(arguments.getTable(0)); if (filter.rightPresent()) @@ -788,4 +802,22 @@ public final MethodResult getCraftingCPUs() throws LuaException { } return MethodResult.of(map); } + + private static final class CapabilityWrapper implements ICapabilityProvider { + private final MeBridgePeripheral peripheral; + + private CapabilityWrapper(MeBridgePeripheral peripheral) { + this.peripheral = peripheral; + } + + @Override + public LazyOptional getCapability(final Capability cap, final Direction side) { + if (cap == ForgeCapabilities.ITEM_HANDLER) { + return LazyOptional.of(this.peripheral::getItemHandler).cast(); + } else if (cap == ForgeCapabilities.FLUID_HANDLER) { + return LazyOptional.of(this.peripheral::getFluidHandler).cast(); + } + return LazyOptional.empty(); + } + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java index 599872d24..77f4e0f98 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java @@ -52,6 +52,11 @@ public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, // The logic changes with storage systems since these systems do not have slots if (inventoryFrom instanceof IStorageSystemItemHandler storageSystemHandler) { + if (inventoryTo instanceof IStorageSystemItemHandler targetSSH) { + ItemStack extracted = storageSystemHandler.extractItem(filter, filter.getCount(), true); + ItemStack remain = targetSSH.insertItem(toSlot, extracted, false); + return storageSystemHandler.extractItem(filter, extracted.getCount() - remain.getCount(), false).getCount(); + } for (int i = toSlot == -1 ? 0 : toSlot; i < (toSlot == -1 ? inventoryTo.getSlots() : toSlot + 1); i++) { ItemStack extracted = storageSystemHandler.extractItem(filter, filter.getCount(), true); if (extracted.isEmpty()) From c51a2c784497273f683f1c80d571ba3586e7e98e Mon Sep 17 00:00:00 2001 From: zyxkad Date: Mon, 17 Mar 2025 14:58:17 -0600 Subject: [PATCH 3/5] implement ICapabilityProvider on rsbridge --- .../peripheral/RsBridgePeripheral.java | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java index d438cf422..c204dbefd 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java @@ -29,6 +29,10 @@ import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandler; @@ -46,6 +50,7 @@ public class RsBridgePeripheral extends BasePeripheral(tileEntity)); @@ -68,11 +73,24 @@ private boolean isAvailable() { return getNetwork() != null; } + @Override + public Object getTarget() { + return capabilityWrapper; + } + @Override public boolean isEnabled() { return APConfig.PERIPHERALS_CONFIG.enableRSBridge.get(); } + protected RsItemHandler getItemHandler() { + return new RsItemHandler(getNetwork()); + } + + protected RsFluidHandler getFluidHandler() { + return new RsFluidHandler(getNetwork()); + } + @Override @LuaFunction(mainThread = true) public final MethodResult isConnected() { @@ -393,7 +411,7 @@ public final MethodResult getPatterns(IArguments arguments) throws LuaException } protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { - RsItemHandler itemHandler = new RsItemHandler(getNetwork()); + RsItemHandler itemHandler = getItemHandler(); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -405,7 +423,7 @@ protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable II } protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { - RsItemHandler itemHandler = new RsItemHandler(getNetwork()); + RsItemHandler itemHandler = getItemHandler(); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -417,7 +435,7 @@ protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable I } protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) throws LuaException { - RsFluidHandler itemHandler = new RsFluidHandler(getNetwork()); + RsFluidHandler itemHandler = getFluidHandler(); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -429,7 +447,7 @@ protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFl } protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) throws LuaException { - RsFluidHandler itemHandler = new RsFluidHandler(getNetwork()); + RsFluidHandler itemHandler = getFluidHandler(); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -714,4 +732,22 @@ public final MethodResult isCraftable(IArguments arguments) throws LuaException return MethodResult.of(RsApi.findPatternFromFilters(getNetwork(), null, parsedFilter).getLeft() != null); } + + private static final class CapabilityWrapper implements ICapabilityProvider { + private final RsBridgePeripheral peripheral; + + private CapabilityWrapper(RsBridgePeripheral peripheral) { + this.peripheral = peripheral; + } + + @Override + public LazyOptional getCapability(final Capability cap, final Direction side) { + if (cap == ForgeCapabilities.ITEM_HANDLER) { + return LazyOptional.of(this.peripheral::getItemHandler).cast(); + } else if (cap == ForgeCapabilities.FLUID_HANDLER) { + return LazyOptional.of(this.peripheral::getFluidHandler).cast(); + } + return LazyOptional.empty(); + } + } } From d41c230332ab16ca6659c53001a06534537a3309 Mon Sep 17 00:00:00 2001 From: zyxkad Date: Mon, 17 Mar 2025 15:02:07 -0600 Subject: [PATCH 4/5] make itemfilter default count as max integer so people can export/import all items when the count is not provided --- .../advancedperipherals/common/util/inventory/ItemFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java index 597d977d7..0c874fc83 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java @@ -27,7 +27,7 @@ public class ItemFilter extends GenericFilter { private TagKey tag = null; private CompoundTag nbt = null; private String nbtHash = null; - private int count = 64; + private int count = Integer.MAX_VALUE; private String fingerprint = ""; public int fromSlot = -1; public int toSlot = -1; From 88705392fce746fc4077ee03c34cee4a5661fd8a Mon Sep 17 00:00:00 2001 From: zyxkad Date: Mon, 17 Mar 2025 15:08:42 -0600 Subject: [PATCH 5/5] make FluidFilter's default count to Integer.MAX_VALUE --- .../advancedperipherals/common/util/inventory/FluidFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java index c4da4be2b..8fa54e6cb 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java @@ -27,7 +27,7 @@ public class FluidFilter extends GenericFilter { private TagKey tag = null; private CompoundTag nbt = null; private String nbtHash = null; - private int count = 1000; + private int count = Integer.MAX_VALUE; private String fingerprint = ""; private FluidFilter() {