Files
Purpur/patches/server/0106-Add-configurable-beehive-generation-chance.patch
William Blake Galbreath ed7b2022b7 Bringing back Tuinity! \o/
2020-06-20 20:40:30 -05:00

108 lines
6.9 KiB
Diff

From 3e3ed022c3baa918e0f2ede87d132473c55f75ac Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 2 Apr 2020 03:39:34 -0500
Subject: [PATCH] Add configurable beehive generation chance
---
.../server/WorldGenFeatureTreeBeehive.java | 18 +++++++++++++--
.../server/WorldGenTreeProvider.java | 5 +++-
.../net/pl3x/purpur/PurpurWorldConfig.java | 23 +++++++++++++++++++
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/src/main/java/net/minecraft/server/WorldGenFeatureTreeBeehive.java b/src/main/java/net/minecraft/server/WorldGenFeatureTreeBeehive.java
index 5827b1ba1..5ef9ae16e 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,7 +23,7 @@ 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) {
+ if (random.nextFloat() < getChance(generatoraccess.getMinecraftWorld(), list.get(0))) {
EnumDirection enumdirection = BlockBeehive.a[random.nextInt(BlockBeehive.a.length)];
int i = !list1.isEmpty() ? Math.max(((BlockPosition) list1.get(0)).getY() - 1, ((BlockPosition) list.get(0)).getY()) : Math.min(((BlockPosition) list.get(0)).getY() + 1 + random.nextInt(3), ((BlockPosition) list.get(list.size() - 1)).getY());
List<BlockPosition> list2 = (List) list.stream().filter((blockposition) -> {
@@ -56,6 +56,20 @@ public class WorldGenFeatureTreeBeehive extends WorldGenFeatureTree {
}
}
+ private float getChance(World world, BlockPosition position) {
+ BiomeBase biome = world.getBiome(position);
+ 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;
+ else if (biome == Biomes.FOREST) return world.purpurConfig.beehivesGenerateForestChance;
+ else if (biome == Biomes.WOODED_HILLS) return world.purpurConfig.beehivesGenerateWoodedHillsChance;
+ else if (biome == Biomes.BIRCH_FOREST) return world.purpurConfig.beehivesGenerateBirchForestChance;
+ else if (biome == Biomes.TALL_BIRCH_FOREST) return world.purpurConfig.beehivesGenerateTallBirchForestChance;
+ else if (biome == Biomes.BIRCH_FOREST_HILLS) return world.purpurConfig.beehivesGenerateBirchForestHillsChance;
+ else if (biome == Biomes.TALL_BIRCH_HILLS) return world.purpurConfig.beehivesGenerateTallBirchHillsChance;
+ return getChance();
+ }
+
@Override
public <T> T a(DynamicOps<T> dynamicops) {
return new Dynamic<>(dynamicops, dynamicops.createMap(ImmutableMap.of(dynamicops.createString("type"), dynamicops.createString(IRegistry.w.getKey(this.a).toString()), dynamicops.createString("probability"), dynamicops.createFloat(this.b)))).getValue(); // Purpur - decompile error
diff --git a/src/main/java/net/minecraft/server/WorldGenTreeProvider.java b/src/main/java/net/minecraft/server/WorldGenTreeProvider.java
index b9dee0e25..9e9d9e643 100644
--- a/src/main/java/net/minecraft/server/WorldGenTreeProvider.java
+++ b/src/main/java/net/minecraft/server/WorldGenTreeProvider.java
@@ -31,7 +31,10 @@ public abstract class WorldGenTreeProvider {
}
private boolean a(GeneratorAccess generatoraccess, BlockPosition blockposition) {
- Iterator iterator = BlockPosition.MutableBlockPosition.a(blockposition.down().north(2).west(2), blockposition.up().south(2).east(2)).iterator();
+ // Purpur start
+ int r = generatoraccess.getMinecraftWorld().purpurConfig.beehivesSaplingFlowerRadius;
+ Iterator iterator = BlockPosition.MutableBlockPosition.a(blockposition.down().north(r).west(r), blockposition.up().south(r).east(r)).iterator();
+ // Purpur end
BlockPosition blockposition1;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index adcdc6b8f..0347b729c 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -99,6 +99,29 @@ public class PurpurWorldConfig {
}
}
+ public int beehivesSaplingFlowerRadius = 2;
+ public float beehivesGeneratePlainsChance = 0.05F;
+ public float beehivesGenerateSunflowerPlainsChance = 0.05F;
+ public float beehivesGenerateFlowerForestChance = 0.01F;
+ public float beehivesGenerateForestChance;
+ public float beehivesGenerateWoodedHillsChance;
+ public float beehivesGenerateBirchForestChance;
+ public float beehivesGenerateTallBirchForestChance;
+ public float beehivesGenerateBirchForestHillsChance;
+ public float beehivesGenerateTallBirchHillsChance;
+ private void beehiveSettings() {
+ beehivesSaplingFlowerRadius = getInt("beehive.grow-sapling-flower-check-radius", beehivesSaplingFlowerRadius);
+ 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);
+ beehivesGenerateForestChance = (float) getDouble("beehive.generation-chance.forest", beehivesGenerateForestChance);
+ beehivesGenerateWoodedHillsChance = (float) getDouble("beehive.generation-chance.wooded-hills", beehivesGenerateWoodedHillsChance);
+ beehivesGenerateBirchForestChance = (float) getDouble("beehive.generation-chance.birch-forest", beehivesGenerateBirchForestChance);
+ beehivesGenerateTallBirchForestChance = (float) getDouble("beehive.generation-chance.tall-birch-forest", beehivesGenerateTallBirchForestChance);
+ beehivesGenerateBirchForestHillsChance = (float) getDouble("beehive.generation-chance.birch-forest-hills", beehivesGenerateBirchForestHillsChance);
+ beehivesGenerateTallBirchHillsChance = (float) getDouble("beehive.generation-chance.tall-birch-hills", beehivesGenerateTallBirchHillsChance);
+ }
+
public int campfireRegenInterval = 0;
public int campfireRegenDuration = 80;
public int campfireRegenRange = 5;
--
2.26.2