Search in sources :

Example 1 with ModularStorageTileEntity

use of mcjty.rftools.blocks.storage.ModularStorageTileEntity in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method createModularStorage.

private void createModularStorage(Random random, World world, BlockPos pos) {
    Block storageBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("rftools", "modular_storage"));
    if (storageBlock instanceof BlockAir)
        return;
    ItemStack module = new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation("rftools", "storage_module")));
    world.setBlockState(pos, storageBlock.getDefaultState().withProperty(BaseBlock.FACING, EnumFacing.HORIZONTALS[random.nextInt(EnumFacing.HORIZONTALS.length)]), 18);
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof ModularStorageTileEntity) {
        ModularStorageTileEntity storage = (ModularStorageTileEntity) te;
        storage.setInventorySlotContents(ModularStorageContainer.SLOT_STORAGE_MODULE, module);
        for (int i = 0; i < 5 + random.nextInt(10); i++) {
            storage.setInventorySlotContents(i + ModularStorageContainer.SLOT_STORAGE, randomLoot(random));
        }
    }
}
Also used : BlockAir(net.minecraft.block.BlockAir) ModularStorageTileEntity(mcjty.rftools.blocks.storage.ModularStorageTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ResourceLocation(net.minecraft.util.ResourceLocation) BaseBlock(mcjty.lib.container.BaseBlock) Block(net.minecraft.block.Block) ModularStorageTileEntity(mcjty.rftools.blocks.storage.ModularStorageTileEntity) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BaseBlock (mcjty.lib.container.BaseBlock)1 ModularStorageTileEntity (mcjty.rftools.blocks.storage.ModularStorageTileEntity)1 Block (net.minecraft.block.Block)1 BlockAir (net.minecraft.block.BlockAir)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1