From ba45df2abe629108d5390ea37db225890b8f0303 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 5 Jan 2020 12:07:28 -0600 Subject: [PATCH] Add configurable beehive generation chance --- .../minecraft/server/WorldGenFeatureTreeBeehive.java | 12 ++++++++++-- src/main/java/net/pl3x/purpur/PurpurWorldConfig.java | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/WorldGenFeatureTreeBeehive.java b/src/main/java/net/minecraft/server/WorldGenFeatureTreeBeehive.java index e85e096cd6..b914bc541f 100644 --- a/src/main/java/net/minecraft/server/WorldGenFeatureTreeBeehive.java +++ b/src/main/java/net/minecraft/server/WorldGenFeatureTreeBeehive.java @@ -10,7 +10,7 @@ import java.util.stream.Collectors; public class WorldGenFeatureTreeBeehive extends WorldGenFeatureTree { - private final float b; + private final float b; public float getChance() { return b; } // Purpur - OBFHELPER public WorldGenFeatureTreeBeehive(float f) { super(WorldGenFeatureTrees.d); @@ -23,8 +23,8 @@ public class WorldGenFeatureTreeBeehive extends WorldGenFeatureTree { @Override public void a(GeneratorAccess generatoraccess, Random random, List list, List list1, Set set, StructureBoundingBox structureboundingbox) { - if (random.nextFloat() < this.b) { // Purpur start + if (random.nextFloat() < getChance(generatoraccess.getMinecraftWorld(), list.get(0))) { if (BlockSapling.growing) { MinecraftServer.getServer().scheduleOnMain(() -> { generate(generatoraccess, random, list, list1, set, structureboundingbox); @@ -35,6 +35,14 @@ public class WorldGenFeatureTreeBeehive extends WorldGenFeatureTree { } } + private float getChance(World world, BlockPosition position) { + BiomeBase biome = world.getBiome(position); + if (biome == Biomes.PLAINS) return world.purpurConfig.beehivesPlainsChance; + else if (biome == Biomes.SUNFLOWER_PLAINS) return world.purpurConfig.beehivesSunflowerPlainsChance; + else if (biome == Biomes.FLOWER_FOREST) return world.purpurConfig.beehivesFlowerForestChance; + return getChance(); + } + private void generate(GeneratorAccess generatoraccess, Random random, List list, List list1, Set set, StructureBoundingBox structureboundingbox) { // Purpur end EnumDirection enumdirection = BlockBeehive.a[random.nextInt(BlockBeehive.a.length)]; diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 340697ae53..f09fdf1c1d 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -145,8 +145,14 @@ public class PurpurWorldConfig { } public boolean beeHivesGenerateFromSaplings = false; + public float beehivesPlainsChance = 0.05F; + public float beehivesSunflowerPlainsChance = 0.05F; + public float beehivesFlowerForestChance = 0.01F; private void beehiveSettings() { beeHivesGenerateFromSaplings = getBoolean("beehive.can-generate-from-saplings", beeHivesGenerateFromSaplings); + beehivesPlainsChance = (float) getDouble("beehive.chance.plains", beehivesPlainsChance); + beehivesSunflowerPlainsChance = (float) getDouble("beehive.chance.sunflower-plains", beehivesSunflowerPlainsChance); + beehivesFlowerForestChance = (float) getDouble("beehive.chance.flower-forest", beehivesFlowerForestChance); } public boolean hayBlockFallDamage = true; -- 2.24.0