Search in sources :

Example 1 with TreeFeature

use of net.minecraft.world.gen.feature.TreeFeature in project SpoornPink by spoorn.

the class AbstractSPTree method generate.

@Override
public boolean generate(FeatureContext<FC> context) {
    Set<BlockPos> changedTrunkBlocks = Sets.newHashSet();
    Set<BlockPos> changedLeafBlocks = Sets.newHashSet();
    StructureWorldAccess world = context.getWorld();
    boolean generated = generate(changedTrunkBlocks, changedLeafBlocks, world, context.getRandom(), context.getOrigin(), context.getConfig());
    if (!generated || changedTrunkBlocks.isEmpty() && changedLeafBlocks.isEmpty()) {
        return false;
    }
    /**
     * Copy vanilla's from {@link TreeFeature}.
     */
    return BlockBox.encompassPositions(Iterables.concat(changedTrunkBlocks, changedLeafBlocks)).map(box -> {
        VoxelSet voxelSet = placeLogsAndLeaves(world, box, changedTrunkBlocks);
        Structure.updateCorner(world, Block.NOTIFY_ALL, voxelSet, box.getMinX(), box.getMinY(), box.getMinZ());
        return true;
    }).orElse(false);
}
Also used : Iterables(com.google.common.collect.Iterables) Random(java.util.Random) Feature(net.minecraft.world.gen.feature.Feature) ModifiableWorld(net.minecraft.world.ModifiableWorld) ArrayList(java.util.ArrayList) Direction(net.minecraft.util.math.Direction) Properties(net.minecraft.state.property.Properties) Lists(com.google.common.collect.Lists) Vec3i(net.minecraft.util.math.Vec3i) Block(net.minecraft.block.Block) TreeFeature(net.minecraft.world.gen.feature.TreeFeature) BlockState(net.minecraft.block.BlockState) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet) FeatureContext(net.minecraft.world.gen.feature.util.FeatureContext) VoxelSet(net.minecraft.util.shape.VoxelSet) Structure(net.minecraft.structure.Structure) WorldAccess(net.minecraft.world.WorldAccess) Set(java.util.Set) BlockPos(net.minecraft.util.math.BlockPos) Sets(com.google.common.collect.Sets) Blocks(net.minecraft.block.Blocks) StructureWorldAccess(net.minecraft.world.StructureWorldAccess) SPTreeConfig(org.spoorn.spoornpink.world.gen.feature.config.SPTreeConfig) Codec(com.mojang.serialization.Codec) BlockBox(net.minecraft.util.math.BlockBox) TestableWorld(net.minecraft.world.TestableWorld) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet) VoxelSet(net.minecraft.util.shape.VoxelSet) BlockPos(net.minecraft.util.math.BlockPos) StructureWorldAccess(net.minecraft.world.StructureWorldAccess)

Aggregations

Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Codec (com.mojang.serialization.Codec)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Set (java.util.Set)1 Block (net.minecraft.block.Block)1 BlockState (net.minecraft.block.BlockState)1 Blocks (net.minecraft.block.Blocks)1 Properties (net.minecraft.state.property.Properties)1 Structure (net.minecraft.structure.Structure)1 BlockBox (net.minecraft.util.math.BlockBox)1 BlockPos (net.minecraft.util.math.BlockPos)1 Direction (net.minecraft.util.math.Direction)1 Vec3i (net.minecraft.util.math.Vec3i)1 BitSetVoxelSet (net.minecraft.util.shape.BitSetVoxelSet)1 VoxelSet (net.minecraft.util.shape.VoxelSet)1 ModifiableWorld (net.minecraft.world.ModifiableWorld)1 StructureWorldAccess (net.minecraft.world.StructureWorldAccess)1