More feature placement options
This commit is contained in:
parent
3512f82775
commit
e05801277e
3 changed files with 32 additions and 5 deletions
|
@ -21,13 +21,14 @@ public class TemplateFeature<FC extends TemplateFeatureConfig> extends Feature<F
|
||||||
new TemplateFeature(
|
new TemplateFeature(
|
||||||
TemplateFeatureConfig.CODEC));
|
TemplateFeatureConfig.CODEC));
|
||||||
|
|
||||||
public static <T extends TemplateFeatureConfig> BCLFeature createAndRegister(ResourceLocation location,
|
public static <T extends TemplateFeatureConfig> BCLFeature createAndRegisterRare(ResourceLocation location,
|
||||||
TemplateFeatureConfig configuration,
|
TemplateFeatureConfig configuration,
|
||||||
int onveEveryChunk) {
|
int onceEveryChunk) {
|
||||||
|
|
||||||
|
|
||||||
return BCLFeatureBuilder
|
return BCLFeatureBuilder
|
||||||
.start(location, INSTANCE)
|
.start(location, INSTANCE)
|
||||||
.decoration(GenerationStep.Decoration.SURFACE_STRUCTURES)
|
.decoration(GenerationStep.Decoration.SURFACE_STRUCTURES)
|
||||||
.oncePerChunks(onveEveryChunk)
|
|
||||||
.squarePlacement()
|
.squarePlacement()
|
||||||
.distanceToTopAndBottom10()
|
.distanceToTopAndBottom10()
|
||||||
.modifier(EnvironmentScanPlacement.scanningFor(Direction.DOWN,
|
.modifier(EnvironmentScanPlacement.scanningFor(Direction.DOWN,
|
||||||
|
@ -37,6 +38,22 @@ public class TemplateFeature<FC extends TemplateFeatureConfig> extends Feature<F
|
||||||
Blocks.LAVA),
|
Blocks.LAVA),
|
||||||
12))
|
12))
|
||||||
.modifier(BiomeFilter.biome())
|
.modifier(BiomeFilter.biome())
|
||||||
|
.oncePerChunks(onceEveryChunk)
|
||||||
|
.buildAndRegister(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends TemplateFeatureConfig> BCLFeature createAndRegister(ResourceLocation location,
|
||||||
|
TemplateFeatureConfig configuration,
|
||||||
|
int count) {
|
||||||
|
|
||||||
|
|
||||||
|
return BCLFeatureBuilder
|
||||||
|
.start(location, INSTANCE)
|
||||||
|
.decoration(GenerationStep.Decoration.SURFACE_STRUCTURES)
|
||||||
|
.count(count)
|
||||||
|
.squarePlacement()
|
||||||
|
.distanceToTopAndBottom10()
|
||||||
|
.onlyInBiome()
|
||||||
.buildAndRegister(configuration);
|
.buildAndRegister(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.util.StringRepresentable;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
|
||||||
public enum StructurePlacementType implements StringRepresentable {
|
public enum StructurePlacementType implements StringRepresentable {
|
||||||
FLOOR, WALL, CEIL, LAVA, UNDER;
|
FLOOR, WALL, CEIL, LAVA, UNDER, FLOOR_FREE_ABOVE;
|
||||||
|
|
||||||
public static final Codec<StructurePlacementType> CODEC = StringRepresentable.fromEnum(StructurePlacementType::values);
|
public static final Codec<StructurePlacementType> CODEC = StringRepresentable.fromEnum(StructurePlacementType::values);
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,8 @@ public class StructureWorldNBT extends StructureNBT {
|
||||||
return canGenerateUnder(level, pos, rotation);
|
return canGenerateUnder(level, pos, rotation);
|
||||||
else if (type == StructurePlacementType.CEIL)
|
else if (type == StructurePlacementType.CEIL)
|
||||||
return canGenerateCeil(level, pos, rotation);
|
return canGenerateCeil(level, pos, rotation);
|
||||||
|
else if (type == StructurePlacementType.FLOOR_FREE_ABOVE)
|
||||||
|
return canGenerateFloorFreeAbove(level, pos, rotation);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +119,14 @@ public class StructureWorldNBT extends StructureNBT {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean canGenerateFloorFreeAbove(LevelAccessor world, BlockPos pos, Rotation rotation) {
|
||||||
|
if (containsBedrock(world, pos)) return false;
|
||||||
|
|
||||||
|
return getAirFractionFoundation(world, pos, rotation) < 0.5
|
||||||
|
&& world.getBlockState(pos.above(2)).is(Blocks.AIR)
|
||||||
|
&& world.getBlockState(pos.above(4)).is(Blocks.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean canGenerateFloor(LevelAccessor world, BlockPos pos, Rotation rotation) {
|
protected boolean canGenerateFloor(LevelAccessor world, BlockPos pos, Rotation rotation) {
|
||||||
if (containsBedrock(world, pos)) return false;
|
if (containsBedrock(world, pos)) return false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue