|
28 | 28 | import net.minecraft.inventory.InventoryBasic; |
29 | 29 | import net.minecraft.inventory.InventoryCrafting; |
30 | 30 | import net.minecraft.item.ItemStack; |
| 31 | +import net.minecraft.util.NonNullList; |
31 | 32 | import org.spongepowered.asm.mixin.Implements; |
32 | 33 | import org.spongepowered.asm.mixin.Interface; |
33 | 34 | import org.spongepowered.asm.mixin.Mixin; |
|
49 | 50 | @Implements(value = @Interface(iface = MinecraftInventoryAdapter.class, prefix = "inventory$")) |
50 | 51 | public abstract class MixinInventoryCrafting implements IInventory, LensProvider<IInventory, ItemStack> { |
51 | 52 |
|
| 53 | + @Shadow private NonNullList<ItemStack> stackList; |
52 | 54 | protected Fabric<IInventory> fabric; |
53 | 55 | protected SlotCollection slots; |
54 | 56 | protected Lens<IInventory, ItemStack> lens; |
55 | 57 |
|
56 | | - @Shadow public abstract int getSizeInventory(); |
57 | | - |
58 | 58 | @Inject(method = "<init>", at = @At("RETURN")) |
59 | 59 | public void onConstructed(CallbackInfo ci) { |
60 | 60 | 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(); |
62 | 62 | this.lens = getRootLens(fabric, ((InventoryAdapter) this)); |
63 | 63 | } |
64 | 64 |
|
65 | 65 | @Override |
66 | 66 | public Lens<IInventory, ItemStack> getRootLens(Fabric<IInventory> fabric, InventoryAdapter<IInventory, ItemStack> adapter) { |
67 | | - if (this.getSizeInventory() == 0) { |
| 67 | + if (this.stackList.size() == 0) { |
68 | 68 | return null; // No Lens when inventory has no slots |
69 | 69 | } |
70 | | - return new OrderedInventoryLensImpl(0, this.getSizeInventory(), 1, this.slots); |
| 70 | + return new OrderedInventoryLensImpl(0, this.stackList.size(), 1, this.slots); |
71 | 71 | } |
72 | 72 |
|
73 | 73 | public SlotProvider<IInventory, ItemStack> inventory$getSlotProvider() { |
|
0 commit comments