Search in sources :

Example 11 with IvBlockCollection

use of ivorius.ivtoolkit.blocks.IvBlockCollection in project RecurrentComplex by Ivorforce.

the class TransformerSingleBlock method transform.

@Override
public void transform(S instanceData, Phase phase, StructureSpawnContext context, IvWorldData worldData, RunTransformer transformer) {
    if (!generatesInPhase(instanceData, phase))
        return;
    IvBlockCollection blockCollection = worldData.blockCollection;
    StructureBoundingBox relevantSourceArea = context.sourceIntersection(BlockAreas.toBoundingBox(blockCollection.area()));
    if (relevantSourceArea == null)
        return;
    BlockPos lowerCoord = StructureBoundingBoxes.min(context.boundingBox);
    int[] areaSize = new int[] { blockCollection.width, blockCollection.height, blockCollection.length };
    // Freeze height to speed up light calculation
    context.freezeHeightMap(context.intersection(context.boundingBox));
    BlockPos.MutableBlockPos worldCoord = new BlockPos.MutableBlockPos();
    for (BlockPos sourceCoord : RCStructureBoundingBoxes.mutablePositions(relevantSourceArea)) {
        IvMutableBlockPos.add(context.transform.applyOn(sourceCoord, worldCoord, areaSize), lowerCoord);
        if (!context.includesComplex(worldCoord))
            continue;
        IBlockState state = blockCollection.getBlockState(sourceCoord);
        if (matches(context.environment, instanceData, sourceCoord, state))
            transformBlock(instanceData, Phase.BEFORE, context, transformer, areaSize, worldCoord, state);
    }
    context.meltHeightMap();
}
Also used : StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) IvMutableBlockPos(ivorius.ivtoolkit.blocks.IvMutableBlockPos) IvMutableBlockPos(ivorius.ivtoolkit.blocks.IvMutableBlockPos) IvBlockCollection(ivorius.ivtoolkit.blocks.IvBlockCollection)

Aggregations

IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)11 BlockPos (net.minecraft.util.math.BlockPos)10 com.google.gson (com.google.gson)6 IvMutableBlockPos (ivorius.ivtoolkit.blocks.IvMutableBlockPos)6 StructureBoundingBoxes (ivorius.ivtoolkit.world.chunk.gen.StructureBoundingBoxes)6 TableDelegate (ivorius.reccomplex.gui.table.TableDelegate)6 TableNavigator (ivorius.reccomplex.gui.table.TableNavigator)6 TableDataSource (ivorius.reccomplex.gui.table.datasource.TableDataSource)6 JsonUtils (ivorius.reccomplex.json.JsonUtils)6 Type (java.lang.reflect.Type)6 Collectors (java.util.stream.Collectors)6 WorldCache (ivorius.ivtoolkit.world.WorldCache)5 Nullable (javax.annotation.Nullable)5 IntegerRange (ivorius.ivtoolkit.gui.IntegerRange)4 LineSelection (ivorius.ivtoolkit.util.LineSelection)4 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)4 PositionedBlockExpression (ivorius.reccomplex.utils.expression.PositionedBlockExpression)4 WorldServer (net.minecraft.world.WorldServer)4 Side (net.minecraftforge.fml.relauncher.Side)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4