Fix conveyors dropping items from creative drawers (#53)

This commit is contained in:
RecursivePineapple authored and GitHub committed 2025-11-19 19:58:37 +01:00
1 parent 28cf99b6e4
commit 02cd6772b1
3 files changed
+16 -2

No files matched your search

@@ -43,6 +43,10 @@ public interface IDrawer {
*/
IDrawer setStoredItemRedir(ItemStack itemPrototype, int amount);
default boolean isVendingUnlimited() {
return false;
}
/**
* Gets the number of items stored in this drawer.
*/
@@ -28,6 +28,7 @@ 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.gtnewhorizon.gtnhlib.util.ItemUtil;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
@@ -1045,6 +1046,10 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
IDrawer drawer = drawers[slot];
if (drawer.isVendingUnlimited()
&& ItemUtil.areStacksEqual(stack.toStackFast(), drawer.getStoredItemPrototype()))
return 0;
ItemStack insertExample = stack.toStackFast();
if (!drawer.canItemBeStored(insertExample)) return stack.getStackSize();
@@ -31,6 +31,11 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
postInit();
}
@Override
public boolean isVendingUnlimited() {
return storageProvider.isVendingUnlimited(slot);
}
@Override
public ItemStack getStoredItemPrototype() {
if (protoStack == nullStack) return null;
@@ -77,7 +82,7 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
@Override
public int getStoredItemCount() {
if (protoStack != nullStack && storageProvider.isVendingUnlimited(slot)) return Integer.MAX_VALUE;
if (protoStack != nullStack && isVendingUnlimited()) return Integer.MAX_VALUE;
return count;
}
@@ -88,7 +93,7 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
}
public void setStoredItemCount(int amount, boolean mark, boolean clearOnEmpty) {
if (storageProvider.isVendingUnlimited(slot)) return;
if (isVendingUnlimited()) return;
count = amount;
if (count > getMaxCapacity()) count = getMaxCapacity();