Skip to content

Commit

Permalink
Update SmartItemHandlerSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaMode committed Sep 5, 2023
1 parent 99b0b44 commit 583a0e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ satin_version = 1.11.0
modmenu_version=7.2.1
cca_version=5.2.2

port_lib_version = 2.1.1135
port_lib_version = 2.1.1136
star_version = 1.5.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

import io.github.fabricators_of_create.porting_lib.transfer.item.SlotItemHandler;
import io.github.fabricators_of_create.porting_lib.transfer.item.SlottedStackStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.minecraft.world.item.ItemStack;

/** Forge still uses dumb vanilla logic for determining slot limits instead of their own method */
public class SmartItemHandlerSlot extends SlotItemHandler {
public SmartItemHandlerSlot(SlottedStackStorage itemHandler, int index, int xPosition, int yPosition) {
public SmartItemHandlerSlot(SlottedStorage<ItemVariant> itemHandler, int index, int xPosition, int yPosition) {
super(itemHandler, index, xPosition, yPosition);
}

@Override
public int getMaxStackSize(ItemStack stack) {
return Math.min(stack.getMaxStackSize(), getItemHandler().getSlotLimit(getSlotIndex()));
var storage = getItemHandler();
return (int) Math.min(stack.getMaxStackSize(), storage instanceof SlottedStackStorage slottedStackStorage ? slottedStackStorage.getSlotLimit(getSlotIndex()): storage.getSlot(getSlotIndex()).getCapacity());
}
}

0 comments on commit 583a0e7

Please sign in to comment.