Skip to content

Commit 4a809dc

Browse files
committed
do not rely on mod not overriding getSizeInventory
1 parent bc80b91 commit 4a809dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/org/spongepowered/common/mixin/core/inventory/MixinInventoryCrafting.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.minecraft.inventory.InventoryBasic;
2929
import net.minecraft.inventory.InventoryCrafting;
3030
import net.minecraft.item.ItemStack;
31+
import net.minecraft.util.NonNullList;
3132
import org.spongepowered.asm.mixin.Implements;
3233
import org.spongepowered.asm.mixin.Interface;
3334
import org.spongepowered.asm.mixin.Mixin;
@@ -49,25 +50,24 @@
4950
@Implements(value = @Interface(iface = MinecraftInventoryAdapter.class, prefix = "inventory$"))
5051
public abstract class MixinInventoryCrafting implements IInventory, LensProvider<IInventory, ItemStack> {
5152

53+
@Shadow private NonNullList<ItemStack> stackList;
5254
protected Fabric<IInventory> fabric;
5355
protected SlotCollection slots;
5456
protected Lens<IInventory, ItemStack> lens;
5557

56-
@Shadow public abstract int getSizeInventory();
57-
5858
@Inject(method = "<init>", at = @At("RETURN"))
5959
public void onConstructed(CallbackInfo ci) {
6060
this.fabric = new DefaultInventoryFabric(this);
61-
this.slots = new SlotCollection.Builder().add(this.getSizeInventory()).build();
61+
this.slots = new SlotCollection.Builder().add(this.stackList.size()).build();
6262
this.lens = getRootLens(fabric, ((InventoryAdapter) this));
6363
}
6464

6565
@Override
6666
public Lens<IInventory, ItemStack> getRootLens(Fabric<IInventory> fabric, InventoryAdapter<IInventory, ItemStack> adapter) {
67-
if (this.getSizeInventory() == 0) {
67+
if (this.stackList.size() == 0) {
6868
return null; // No Lens when inventory has no slots
6969
}
70-
return new OrderedInventoryLensImpl(0, this.getSizeInventory(), 1, this.slots);
70+
return new OrderedInventoryLensImpl(0, this.stackList.size(), 1, this.slots);
7171
}
7272

7373
public SlotProvider<IInventory, ItemStack> inventory$getSlotProvider() {

0 commit comments

Comments
 (0)