use of org.spongepowered.common.accessor.world.inventory.ResultSlotAccessor in project SpongeCommon by SpongePowered.
the class ContainerUtil method generateAdapterLens.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Lens generateAdapterLens(final SlotLensProvider slots, final int index, final org.spongepowered.common.inventory.util.ContainerUtil.CraftingInventoryData crafting, final List<Slot> slotList, final net.minecraft.world.@Nullable Container subInventory) {
Lens lens = ((InventoryBridge) subInventory).bridge$getAdapter().inventoryAdapter$getRootLens();
if (lens instanceof PlayerInventoryLens) {
if (slotList.size() == 36) {
return new DelegatingLens(index, new PrimaryPlayerInventoryLens(0, slots, true), slots);
}
return lens;
}
// For Crafting Result we need the Slot to get Filter logic
if (subInventory instanceof ResultContainer) {
final Slot slot = slotList.get(0);
if (slot instanceof ResultSlotAccessor) {
crafting.out = index;
if (crafting.base == null) {
// In case we do not find the InventoryCrafting later assume it is directly after the SlotCrafting
// e.g. for IC2 ContainerIndustrialWorkbench
crafting.base = index + 1;
crafting.grid = ((ResultSlotAccessor) slot).accessor$craftSlots();
}
}
}
if (subInventory instanceof CraftingContainer) {
crafting.base = index;
crafting.grid = ((CraftingContainer) subInventory);
}
return new DelegatingLens(index, slotList, lens, slots);
}
Aggregations