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());
}
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);
}
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));
}
}
Aggregations