Rubber trees are less frequent and have configs. Closes

This commit is contained in:
drcrazy 2020-04-06 14:24:35 +03:00
parent 0845b923b5
commit 294f4b5454
4 changed files with 17 additions and 7 deletions

View file

@ -635,6 +635,15 @@ public class TechRebornConfig {
@Config(config = "world", category = "ore", key = "enableTungstenOre", comment = "Generate Tungsten Ore in The End.")
public static boolean enableTungstenOre = true;
@Config(config = "world", category = "rubber_tree", key = "RubberTreeChance", comment = "Chance to spawn rubber tree")
public static float RubberTreeChance = 0.1F;
@Config(config = "world", category = "rubber_tree", key = "RubberTreeCount", comment = "Amount of trees to spawn in successful case")
public static int RubberTreeCount = 1;
@Config(config = "world", category = "rubber_tree", key = "RubberTreeBaseHeight", comment = "Basic height for not-spire part of rubber tree")
public static int RubberTreeBaseHeight = 6;
@Config(config = "world", category = "rubber_tree", key = "RubberTreeSpireHeight", comment = "Height of spire of rubber tree")
public static int RubberTreeSpireHeight = 3;
}

View file

@ -43,6 +43,6 @@ public class RubberSaplingGenerator extends SaplingGenerator {
@Nullable
@Override
protected ConfiguredFeature<BranchedTreeFeatureConfig, ?> createTreeFeature(Random random, boolean bl) {
return WorldGenerator.RUBBER_TREE.configure(WorldGenerator.RUBBER_TREE_CONFIG);
return WorldGenerator.RUBBER_TREE_FEATURE.configure(WorldGenerator.RUBBER_TREE_CONFIG);
}
}

View file

@ -31,6 +31,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ModifiableTestableWorld;
import net.minecraft.world.gen.feature.BranchedTreeFeatureConfig;
import net.minecraft.world.gen.feature.OakTreeFeature;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import java.util.Random;
@ -70,7 +71,7 @@ public class RubberTreeFeature extends OakTreeFeature {
if(topPos == null) return;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < TechRebornConfig.RubberTreeSpireHeight; i++) {
setBlockState(world, pos.up(i), TRContent.RUBBER_LEAVES.getDefaultState());
}
}

View file

@ -58,7 +58,7 @@ import java.util.List;
*/
public class WorldGenerator {
public static Feature<BranchedTreeFeatureConfig> RUBBER_TREE;
public static Feature<BranchedTreeFeatureConfig> RUBBER_TREE_FEATURE;
public static BranchedTreeFeatureConfig RUBBER_TREE_CONFIG;
@ -76,7 +76,7 @@ public class WorldGenerator {
}
private static void setupTrees() {
RUBBER_TREE = Registry.register(Registry.FEATURE, new Identifier("techreborn:rubber_tree"), new RubberTreeFeature(BranchedTreeFeatureConfig::deserialize));
RUBBER_TREE_FEATURE = Registry.register(Registry.FEATURE, new Identifier("techreborn:rubber_tree"), new RubberTreeFeature(BranchedTreeFeatureConfig::deserialize));
WeightedStateProvider logProvider = new WeightedStateProvider();
logProvider.addState(TRContent.RUBBER_LOG.getDefaultState(), 10);
@ -93,7 +93,7 @@ public class WorldGenerator {
logProvider,
new SimpleStateProvider(TRContent.RUBBER_LEAVES.getDefaultState()),
new BlobFoliagePlacer(2, 0))
.baseHeight(6)
.baseHeight(TechRebornConfig.RubberTreeBaseHeight)
.heightRandA(2)
.foliageHeight(3)
.noVines()
@ -162,9 +162,9 @@ public class WorldGenerator {
if (biome.getCategory() == Category.FOREST || biome.getCategory() == Category.TAIGA || biome.getCategory() == Category.SWAMP) {
biome.addFeature(GenerationStep.Feature.VEGETAL_DECORATION,
RUBBER_TREE.configure(RUBBER_TREE_CONFIG)
RUBBER_TREE_FEATURE.configure(RUBBER_TREE_CONFIG)
.createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP
.configure(new CountExtraChanceDecoratorConfig(biome.getCategory() == Category.SWAMP ? 2 : 1, 0.1F, 1))
.configure(new CountExtraChanceDecoratorConfig(biome.getCategory() == Category.SWAMP ? 1 : 0, TechRebornConfig.RubberTreeChance, TechRebornConfig.RubberTreeCount))
)
);
}