Steep rules & cleanup
This commit is contained in:
parent
9609db9f9b
commit
bf1b3917f4
3 changed files with 28 additions and 29 deletions
|
@ -4,15 +4,8 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.levelgen.Noises;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.api.WorldDataAPI;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.api.biomes.SurfaceRuleBuilder;
|
||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||
import ru.bclib.api.dataexchange.handler.autosync.Chunker;
|
||||
import ru.bclib.api.dataexchange.handler.autosync.HelloClient;
|
||||
|
@ -56,17 +49,6 @@ public class BCLib implements ModInitializer {
|
|||
|
||||
BCLibPatch.register();
|
||||
Configs.save();
|
||||
|
||||
RuleSource rule = SurfaceRuleBuilder
|
||||
.start()
|
||||
.biome(Biomes.END_HIGHLANDS)
|
||||
.filler(Blocks.STONE.defaultBlockState())
|
||||
.subsurface(Blocks.DIRT.defaultBlockState(), 3)
|
||||
.surface(Blocks.GRASS_BLOCK.defaultBlockState())
|
||||
.aboveCeil(Blocks.DEEPSLATE.defaultBlockState(), 4)
|
||||
.ceil(Blocks.BASALT.defaultBlockState())
|
||||
.build();
|
||||
BiomeAPI.addSurfaceRule(Biomes.END_HIGHLANDS.location(), rule);
|
||||
}
|
||||
|
||||
public static boolean isDevEnvironment() {
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.world.level.levelgen.Noises;
|
|||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.CaveSurface;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import ru.bclib.util.ColorUtil;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
@ -494,7 +493,7 @@ public class BCLBiomeBuilder {
|
|||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder surface(Block surfaceBlock) {
|
||||
return surface(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.state(surfaceBlock.defaultBlockState())));
|
||||
return surface(SurfaceRuleBuilder.start().surface(surfaceBlock.defaultBlockState()).build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -505,11 +504,11 @@ public class BCLBiomeBuilder {
|
|||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder surface(Block surfaceBlock, Block subterrainBlock, int depth) {
|
||||
SurfaceRules.RuleSource topRule = SurfaceRules.state(surfaceBlock.defaultBlockState());
|
||||
SurfaceRules.RuleSource subterrainRule = SurfaceRules.state(subterrainBlock.defaultBlockState());
|
||||
topRule = SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, topRule);
|
||||
subterrainRule = SurfaceRules.ifTrue(SurfaceRules.stoneDepthCheck(depth, false, false, CaveSurface.FLOOR), subterrainRule);
|
||||
return surface(SurfaceRules.sequence(topRule, subterrainRule));
|
||||
return surface(SurfaceRuleBuilder
|
||||
.start()
|
||||
.surface(surfaceBlock.defaultBlockState())
|
||||
.subsurface(subterrainBlock.defaultBlockState(), depth)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,7 @@ public class SurfaceRuleBuilder {
|
|||
entryInstance = getFromCache("surface_" + state.toString(), () -> {
|
||||
RuleSource rule = SurfaceRules.state(state);
|
||||
rule = SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, rule);
|
||||
return new SurfaceRuleEntry(1, rule);
|
||||
return new SurfaceRuleEntry(2, rule);
|
||||
});
|
||||
rules.add(entryInstance);
|
||||
return this;
|
||||
|
@ -73,7 +73,7 @@ public class SurfaceRuleBuilder {
|
|||
entryInstance = getFromCache("subsurface_" + depth + "_" + state.toString(), () -> {
|
||||
RuleSource rule = SurfaceRules.state(state);
|
||||
rule = SurfaceRules.ifTrue(SurfaceRules.stoneDepthCheck(depth, false, false, CaveSurface.FLOOR), rule);
|
||||
return new SurfaceRuleEntry(2, rule);
|
||||
return new SurfaceRuleEntry(3, rule);
|
||||
});
|
||||
rules.add(entryInstance);
|
||||
return this;
|
||||
|
@ -98,7 +98,7 @@ public class SurfaceRuleBuilder {
|
|||
public SurfaceRuleBuilder ceil(BlockState state) {
|
||||
entryInstance = getFromCache("ceil_" + state.toString(), () -> {
|
||||
RuleSource rule = SurfaceRules.state(state);
|
||||
return new SurfaceRuleEntry(1, SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, rule));
|
||||
return new SurfaceRuleEntry(2, SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, rule));
|
||||
});
|
||||
rules.add(entryInstance);
|
||||
return this;
|
||||
|
@ -114,7 +114,25 @@ public class SurfaceRuleBuilder {
|
|||
entryInstance = getFromCache("above_ceil_" + height + "_" + state.toString(), () -> {
|
||||
RuleSource rule = SurfaceRules.state(state);
|
||||
rule = SurfaceRules.ifTrue(SurfaceRules.stoneDepthCheck(height, false, false, CaveSurface.CEILING), rule);
|
||||
return new SurfaceRuleEntry(2, rule);
|
||||
return new SurfaceRuleEntry(3, rule);
|
||||
});
|
||||
rules.add(entryInstance);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will cover steep areas (with large terrain angle). Example - Overworld mountains.
|
||||
* @param state {@link BlockState} for the steep layer.
|
||||
* @param depth layer depth
|
||||
* @return
|
||||
*/
|
||||
public SurfaceRuleBuilder steep(BlockState state, int depth) {
|
||||
entryInstance = getFromCache("steep_" + depth + "_" + state.toString(), () -> {
|
||||
RuleSource rule = SurfaceRules.state(state);
|
||||
rule = SurfaceRules.ifTrue(SurfaceRules.stoneDepthCheck(depth, false, false, CaveSurface.FLOOR), rule);
|
||||
rule = SurfaceRules.ifTrue(SurfaceRules.steep(), rule);
|
||||
int priority = depth < 1 ? 0 : 1;
|
||||
return new SurfaceRuleEntry(priority, rule);
|
||||
});
|
||||
rules.add(entryInstance);
|
||||
return this;
|
||||
|
|
Loading…
Reference in a new issue