41 lines
1.5 KiB
Java
41 lines
1.5 KiB
Java
package net.minecraft.world.level.levelgen.feature.trunkplacers;
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.mojang.serialization.MapCodec;
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
import java.util.List;
|
|
import java.util.function.BiConsumer;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.world.level.LevelSimulatedReader;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
|
import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer.FoliageAttachment;
|
|
|
|
public class StraightTrunkPlacer extends TrunkPlacer {
|
|
public static final MapCodec<StraightTrunkPlacer> CODEC = RecordCodecBuilder.mapCodec(
|
|
instance -> trunkPlacerParts(instance).apply(instance, StraightTrunkPlacer::new)
|
|
);
|
|
|
|
public StraightTrunkPlacer(int i, int j, int k) {
|
|
super(i, j, k);
|
|
}
|
|
|
|
@Override
|
|
protected TrunkPlacerType<?> type() {
|
|
return TrunkPlacerType.STRAIGHT_TRUNK_PLACER;
|
|
}
|
|
|
|
@Override
|
|
public List<FoliageAttachment> placeTrunk(
|
|
LevelSimulatedReader level, BiConsumer<BlockPos, BlockState> blockSetter, RandomSource random, int freeTreeHeight, BlockPos pos, TreeConfiguration config
|
|
) {
|
|
setDirtAt(level, blockSetter, random, pos.below(), config);
|
|
|
|
for (int i = 0; i < freeTreeHeight; i++) {
|
|
this.placeLog(level, blockSetter, random, pos.above(i), config);
|
|
}
|
|
|
|
return ImmutableList.of(new FoliageAttachment(pos.above(freeTreeHeight), 0, false));
|
|
}
|
|
}
|