Search in sources :

Example 1 with IMultiSlotItemHandler

use of com.almuradev.almura.shared.capability.IMultiSlotItemHandler in project Almura by AlmuraDev.

the class StorageBlock method createNewTileEntity.

@Nullable
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
    final MultiSlotTileEntity mte = new MultiSlotTileEntity();
    final IMultiSlotItemHandler itemHandler = (MultiSlotItemHandler) mte.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    if (this.slotAmount > itemHandler.getSlots()) {
        itemHandler.resize(this.slotAmount);
    }
    return mte;
}
Also used : MultiSlotItemHandler(com.almuradev.almura.shared.capability.impl.MultiSlotItemHandler) IMultiSlotItemHandler(com.almuradev.almura.shared.capability.IMultiSlotItemHandler) MultiSlotTileEntity(com.almuradev.almura.shared.tileentity.MultiSlotTileEntity) IMultiSlotItemHandler(com.almuradev.almura.shared.capability.IMultiSlotItemHandler) Nullable(javax.annotation.Nullable)

Example 2 with IMultiSlotItemHandler

use of com.almuradev.almura.shared.capability.IMultiSlotItemHandler in project Almura by AlmuraDev.

the class MultiSlotTileEntity method onLoad.

@Override
public void onLoad() {
    final IMultiSlotItemHandler itemHandler = (IMultiSlotItemHandler) this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    final IBlockState state = this.world.getBlockState(this.pos);
    final Block block = state.getBlock();
    if (block instanceof StorageBlock) {
        final int slotCount = ((StorageBlock) block).getSlotCount();
        itemHandler.resize(slotCount);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) StorageBlock(com.almuradev.almura.feature.storage.block.StorageBlock) Block(net.minecraft.block.Block) IMultiSlotItemHandler(com.almuradev.almura.shared.capability.IMultiSlotItemHandler) StorageBlock(com.almuradev.almura.feature.storage.block.StorageBlock)

Aggregations

IMultiSlotItemHandler (com.almuradev.almura.shared.capability.IMultiSlotItemHandler)2 StorageBlock (com.almuradev.almura.feature.storage.block.StorageBlock)1 MultiSlotItemHandler (com.almuradev.almura.shared.capability.impl.MultiSlotItemHandler)1 MultiSlotTileEntity (com.almuradev.almura.shared.tileentity.MultiSlotTileEntity)1 Nullable (javax.annotation.Nullable)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1