Search in sources :

Example 1 with BlockInfo

use of gregtech.api.util.BlockInfo in project GregTech by GregTechCE.

the class LargeTurbineInfo method getMatchingShapes.

@Override
public List<MultiblockShapeInfo> getMatchingShapes() {
    MetaTileEntityHolder holder = new MetaTileEntityHolder();
    holder.setMetaTileEntity(MetaTileEntities.ROTOR_HOLDER[2]);
    holder.getMetaTileEntity().setFrontFacing(EnumFacing.WEST);
    ItemStack rotorStack = MetaItems.TURBINE_ROTOR.getStackForm();
    // noinspection ConstantConditions
    TurbineRotorBehavior.getInstanceFor(rotorStack).setPartMaterial(rotorStack, Materials.Darmstadtium);
    ((MetaTileEntityRotorHolder) holder.getMetaTileEntity()).getRotorInventory().setStackInSlot(0, rotorStack);
    MultiblockShapeInfo.Builder shapeInfo = MultiblockShapeInfo.builder().aisle("CCCC", "CIOC", "CCCC").aisle("CCCC", "R##D", "CCCC").aisle("CCCC", "CSCC", "CCCC").where('S', turbine, EnumFacing.SOUTH).where('C', turbine.turbineType.casingState).where('R', new BlockInfo(MetaBlocks.MACHINE.getDefaultState(), holder)).where('D', MetaTileEntities.ENERGY_OUTPUT_HATCH[GTValues.EV], EnumFacing.EAST).where('#', Blocks.AIR.getDefaultState()).where('I', MetaTileEntities.FLUID_IMPORT_HATCH[GTValues.HV], EnumFacing.NORTH);
    if (turbine.turbineType.hasOutputHatch) {
        shapeInfo.where('O', MetaTileEntities.FLUID_EXPORT_HATCH[GTValues.EV], EnumFacing.NORTH);
    } else {
        shapeInfo.where('O', turbine.turbineType.casingState);
    }
    return Lists.newArrayList(shapeInfo.build());
}
Also used : MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) BlockInfo(gregtech.api.util.BlockInfo) MultiblockShapeInfo(gregtech.integration.jei.multiblock.MultiblockShapeInfo) ItemStack(net.minecraft.item.ItemStack)

Example 2 with BlockInfo

use of gregtech.api.util.BlockInfo in project GregTech by GregTechCE.

the class MultiblockInfoRecipeWrapper method initializePattern.

private MBPattern initializePattern(MultiblockShapeInfo shapeInfo, Set<ItemStackKey> blockDrops) {
    Map<BlockPos, BlockInfo> blockMap = new HashMap<>();
    BlockInfo[][][] blocks = shapeInfo.getBlocks();
    for (int z = 0; z < blocks.length; z++) {
        BlockInfo[][] aisle = blocks[z];
        for (int y = 0; y < aisle.length; y++) {
            BlockInfo[] column = aisle[y];
            for (int x = 0; x < column.length; x++) {
                BlockPos blockPos = new BlockPos(x, y, z);
                BlockInfo blockInfo = column[x];
                blockMap.put(blockPos, blockInfo);
            }
        }
    }
    WorldSceneRenderer worldSceneRenderer = new WorldSceneRenderer(blockMap);
    worldSceneRenderer.world.updateEntities();
    HashMap<ItemStackKey, PartInfo> partsMap = new HashMap<>();
    gatherBlockDrops(worldSceneRenderer.world, blockMap, blockDrops, partsMap);
    worldSceneRenderer.setRenderCallback(this);
    worldSceneRenderer.setRenderFilter(this::shouldDisplayBlock);
    ArrayList<PartInfo> partInfos = new ArrayList<>(partsMap.values());
    partInfos.sort((one, two) -> {
        if (one.isController)
            return -1;
        if (two.isController)
            return +1;
        if (one.isTile && !two.isTile)
            return -1;
        if (two.isTile && !one.isTile)
            return +1;
        if (one.blockId != two.blockId)
            return two.blockId - one.blockId;
        return two.amount - one.amount;
    });
    ArrayList<ItemStack> parts = new ArrayList<>();
    for (PartInfo partInfo : partInfos) {
        parts.add(partInfo.getItemStack());
    }
    return new MBPattern(worldSceneRenderer, parts);
}
Also used : WorldSceneRenderer(gregtech.api.render.scene.WorldSceneRenderer) ItemStackKey(gregtech.api.util.ItemStackKey) BlockInfo(gregtech.api.util.BlockInfo) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 3 with BlockInfo

use of gregtech.api.util.BlockInfo in project GregTech by GregTechCE.

the class MultiblockInfoRecipeWrapper method gatherBlockDrops.

private static void gatherBlockDrops(World world, Map<BlockPos, BlockInfo> blocks, Set<ItemStackKey> drops, Map<ItemStackKey, PartInfo> partsMap) {
    NonNullList<ItemStack> dropsList = NonNullList.create();
    for (Entry<BlockPos, BlockInfo> entry : blocks.entrySet()) {
        BlockPos pos = entry.getKey();
        IBlockState blockState = world.getBlockState(pos);
        NonNullList<ItemStack> blockDrops = NonNullList.create();
        blockState.getBlock().getDrops(blockDrops, world, pos, blockState, 0);
        dropsList.addAll(blockDrops);
        for (ItemStack itemStack : blockDrops) {
            ItemStackKey itemStackKey = new ItemStackKey(itemStack);
            PartInfo partInfo = partsMap.get(itemStackKey);
            if (partInfo == null) {
                partInfo = new PartInfo(itemStackKey, entry.getValue());
                partsMap.put(itemStackKey, partInfo);
            }
            ++partInfo.amount;
        }
    }
    for (ItemStack itemStack : dropsList) {
        drops.add(new ItemStackKey(itemStack));
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockInfo(gregtech.api.util.BlockInfo) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) ItemStackKey(gregtech.api.util.ItemStackKey)

Aggregations

BlockInfo (gregtech.api.util.BlockInfo)3 ItemStack (net.minecraft.item.ItemStack)3 ItemStackKey (gregtech.api.util.ItemStackKey)2 BlockPos (net.minecraft.util.math.BlockPos)2 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)1 WorldSceneRenderer (gregtech.api.render.scene.WorldSceneRenderer)1 MultiblockShapeInfo (gregtech.integration.jei.multiblock.MultiblockShapeInfo)1 IBlockState (net.minecraft.block.state.IBlockState)1