mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
83 lines
4.7 KiB
Diff
83 lines
4.7 KiB
Diff
From 04ca8f191b83e609498db65956691ecdceeaae62 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Sun, 5 Jan 2020 12:07:28 -0600
|
|
Subject: [PATCH] Add configurable beehive generation chance
|
|
|
|
---
|
|
.../server/WorldGenFeatureTreeBeehive.java | 18 ++++++++++++++++--
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 12 ++++++++++++
|
|
2 files changed, 28 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..ca4b5b77fb 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<BlockPosition> list, List<BlockPosition> list1, Set<BlockPosition> 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,20 @@ public class WorldGenFeatureTreeBeehive extends WorldGenFeatureTree {
|
|
}
|
|
}
|
|
|
|
+ private float getChance(World world, BlockPosition position) {
|
|
+ BiomeBase biome = world.getBiome(position);
|
|
+ if (BlockSapling.growing) {
|
|
+ if (biome == Biomes.PLAINS) return world.purpurConfig.beehivesGrowPlainsChance;
|
|
+ else if (biome == Biomes.SUNFLOWER_PLAINS) return world.purpurConfig.beehivesGrowSunflowerPlainsChance;
|
|
+ else if (biome == Biomes.FLOWER_FOREST) return world.purpurConfig.beehivesGrowFlowerForestChance;
|
|
+ } else {
|
|
+ if (biome == Biomes.PLAINS) return world.purpurConfig.beehivesGeneratePlainsChance;
|
|
+ else if (biome == Biomes.SUNFLOWER_PLAINS) return world.purpurConfig.beehivesGenerateSunflowerPlainsChance;
|
|
+ else if (biome == Biomes.FLOWER_FOREST) return world.purpurConfig.beehivesGenerateFlowerForestChance;
|
|
+ }
|
|
+ return getChance();
|
|
+ }
|
|
+
|
|
private void generate(GeneratorAccess generatoraccess, Random random, List<BlockPosition> list, List<BlockPosition> list1, Set<BlockPosition> 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..64e00258ac 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -145,8 +145,20 @@ public class PurpurWorldConfig {
|
|
}
|
|
|
|
public boolean beeHivesGenerateFromSaplings = false;
|
|
+ public float beehivesGeneratePlainsChance = 0.05F;
|
|
+ public float beehivesGenerateSunflowerPlainsChance = 0.05F;
|
|
+ public float beehivesGenerateFlowerForestChance = 0.01F;
|
|
+ public float beehivesGrowPlainsChance = 0.05F;
|
|
+ public float beehivesGrowSunflowerPlainsChance = 0.05F;
|
|
+ public float beehivesGrowFlowerForestChance = 0.01F;
|
|
private void beehiveSettings() {
|
|
beeHivesGenerateFromSaplings = getBoolean("beehive.can-generate-from-saplings", beeHivesGenerateFromSaplings);
|
|
+ beehivesGeneratePlainsChance = (float) getDouble("beehive.generation-chance.plains", beehivesGeneratePlainsChance);
|
|
+ beehivesGenerateSunflowerPlainsChance = (float) getDouble("beehive.generation-chance.sunflower-plains", beehivesGenerateSunflowerPlainsChance);
|
|
+ beehivesGenerateFlowerForestChance = (float) getDouble("beehive.generation-chance.flower-forest", beehivesGenerateFlowerForestChance);
|
|
+ beehivesGrowPlainsChance = (float) getDouble("beehive.grow-chance.plains", beehivesGrowPlainsChance);
|
|
+ beehivesGrowSunflowerPlainsChance = (float) getDouble("beehive.grow-chance.sunflower-plains", beehivesGrowSunflowerPlainsChance);
|
|
+ beehivesGrowFlowerForestChance = (float) getDouble("beehive.grow-chance.flower-forest", beehivesGrowFlowerForestChance);
|
|
}
|
|
|
|
public boolean hayBlockFallDamage = true;
|
|
--
|
|
2.24.0
|
|
|