Integrate with item transferring API (#52)

Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
RecursivePineappleandMartin Robertz authored and GitHub committed 2025-11-14 22:18:03 +01:00
1 parent 4be3fd979c
commit 28cf99b6e4
9 files changed
+113 -15

No files matched your search

+8 -6
View File
@@ -1,14 +1,16 @@
// Add your dependencies here
dependencies {
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta62:api')
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-718-GTNH:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.64:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.8.19-GTNH:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:waila:1.9.2:dev') {transitive=false}
implementation("com.github.GTNewHorizons:GTNHLib:0.8.6:dev")
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta68:api')
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-742-GTNH:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.106:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.8.37-GTNH:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:waila:1.9.9:dev') {transitive=false}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('curse.maven:refined-relocation-75811:2262970')
compileOnly('curse.maven:minetweaker3-224029:2255759')
compileOnly("com.github.GTNewHorizons:Avaritia:1.77:dev")
compileOnly("com.github.GTNewHorizons:Avaritia:1.78:dev")
compileOnly("com.github.GTNewHorizons:Backhand:1.8.0:dev")
compileOnly("org.jetbrains:annotations:26.0.2")
}
+9 -1
View File
@@ -96,7 +96,9 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -172,6 +174,12 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -2
View File
@@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+2 -2
View File
@@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
}
@@ -40,7 +40,7 @@ import cpw.mods.fml.relauncher.Side;
modid = StorageDrawers.MOD_ID,
name = StorageDrawers.MOD_NAME,
version = StorageDrawers.MOD_VERSION,
dependencies = "after:waila;",
dependencies = "after:waila;required-after:gtnhlib;",
guiFactory = StorageDrawers.SOURCE_PATH + "core.ModGuiFactory")
public class StorageDrawers {
@@ -15,9 +15,19 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import org.apache.logging.log4j.Level;
import org.jetbrains.annotations.NotNull;
import com.gtnewhorizon.gtnhlib.capability.CapabilityProvider;
import com.gtnewhorizon.gtnhlib.capability.item.ItemIO;
import com.gtnewhorizon.gtnhlib.capability.item.ItemSink;
import com.gtnewhorizon.gtnhlib.capability.item.ItemSource;
import com.gtnewhorizon.gtnhlib.item.AbstractInventoryIterator;
import com.gtnewhorizon.gtnhlib.item.ImmutableItemStack;
import com.gtnewhorizon.gtnhlib.item.InventoryIterator;
import com.gtnewhorizon.gtnhlib.item.SimpleItemIO;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
@@ -39,9 +49,10 @@ import com.jaquadro.minecraft.storagedrawers.storage.IUpgradeProvider;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import it.unimi.dsi.fastutil.ints.IntIterators;
public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawerGroupInteractive, ISidedInventory,
IUpgradeProvider, ILockable, ISealable, IProtectable, IDowngradable {
IUpgradeProvider, ILockable, ISealable, IProtectable, IDowngradable, CapabilityProvider {
private IDrawer[] drawers;
private IDrawerInventory inventory;
@@ -977,4 +988,81 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
return autoSides;
}
}
private DrawerItemIO io;
@Override
public <T> @Nullable T getCapability(@NotNull Class<T> capability, @NotNull ForgeDirection side) {
if (capability == ItemSource.class || capability == ItemSink.class || capability == ItemIO.class) {
if (io == null) io = new DrawerItemIO();
return capability.cast(io);
}
return null;
}
private class DrawerItemIO extends SimpleItemIO {
private final int[] presentSlots = IntIterators.unwrap(IntIterators.fromTo(0, drawers.length));
@Override
protected @NotNull InventoryIterator iterator(int[] allowedSlots) {
return new AbstractInventoryIterator(presentSlots, allowedSlots) {
@Override
protected ItemStack getStackInSlot(int slot) {
if (slot < 0 || slot >= drawers.length) return null;
return drawers[slot].getStoredItemCopy();
}
@Override
public ItemStack extract(int amount, boolean forced) {
int slot = getCurrentSlot();
if (slot < 0 || slot >= drawers.length) return null;
IDrawer drawer = drawers[slot];
ItemStack stored = drawer.getStoredItemCopy();
if (stored == null) return null;
int toExtract = Math.min(stored.stackSize, amount);
stored.stackSize = toExtract;
drawer.setStoredItemCount(drawer.getStoredItemCount() - toExtract);
return stored;
}
@Override
public int insert(ImmutableItemStack stack, boolean forced) {
int slot = getCurrentSlot();
if (slot < 0 || slot >= drawers.length) return stack.getStackSize();
IDrawer drawer = drawers[slot];
ItemStack insertExample = stack.toStackFast();
if (!drawer.canItemBeStored(insertExample)) return stack.getStackSize();
int capacity = forced ? Integer.MAX_VALUE : drawer.getMaxCapacity(insertExample);
int remaining = capacity - drawer.getStoredItemCount();
int toInsert = Math.min(remaining, stack.getStackSize());
if (drawer.getStoredItemPrototype() == null) {
drawer.setStoredItemRedir(stack.toStack(1), toInsert);
} else {
drawer.setStoredItemCount(drawer.getStoredItemCount() + toInsert);
}
return stack.getStackSize() - toInsert;
}
};
}
}
}