mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
75 lines
5.4 KiB
Diff
75 lines
5.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Mon, 23 Aug 2021 20:57:04 -0500
|
|
Subject: [PATCH] Chance for azalea blocks to grow into trees naturally
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java b/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java
|
|
index b04d224c23ed0039b86aa4169ce38c4f57cc1a7a..1daffadecee2b830b28377e2549d422922b0007b 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java
|
|
@@ -42,6 +42,20 @@ public class AzaleaBlock extends BushBlock implements BonemealableBlock {
|
|
|
|
@Override
|
|
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
|
|
+ // Purpur start
|
|
+ growTree(world, random, pos, state);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void randomTick(net.minecraft.world.level.block.state.BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
|
+ double chance = state.getBlock() == Blocks.FLOWERING_AZALEA ? world.purpurConfig.floweringAzaleaGrowthChance : world.purpurConfig.azaleaGrowthChance;
|
|
+ if (chance > 0.0D && world.getMaxLocalRawBrightness(pos.above()) > 9 && random.nextDouble() < chance) {
|
|
+ growTree(world, random, pos, state);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void growTree(ServerLevel world, RandomSource random, BlockPos pos, net.minecraft.world.level.block.state.BlockState state) {
|
|
+ // Purpur end
|
|
TREE_GROWER.growTree(world, world.getChunkSource().getGenerator(), pos, state, random);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java
|
|
index bcc1ce196c1dbf60cf6ae73d95766dc41ed22012..ad0ee0d333ffd862fe74ac3a097c51d5550803df 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Blocks.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Blocks.java
|
|
@@ -1027,8 +1027,8 @@ public class Blocks {
|
|
public static final Block CAVE_VINES = register("cave_vines", new CaveVinesBlock(BlockBehaviour.Properties.of(Material.PLANT).randomTicks().noCollission().lightLevel(CaveVines.emission(14)).instabreak().sound(SoundType.CAVE_VINES)));
|
|
public static final Block CAVE_VINES_PLANT = register("cave_vines_plant", new CaveVinesPlantBlock(BlockBehaviour.Properties.of(Material.PLANT).noCollission().lightLevel(CaveVines.emission(14)).instabreak().sound(SoundType.CAVE_VINES)));
|
|
public static final Block SPORE_BLOSSOM = register("spore_blossom", new SporeBlossomBlock(BlockBehaviour.Properties.of(Material.PLANT).instabreak().noCollission().sound(SoundType.SPORE_BLOSSOM)));
|
|
- public static final Block AZALEA = register("azalea", new AzaleaBlock(BlockBehaviour.Properties.of(Material.PLANT).instabreak().sound(SoundType.AZALEA).noOcclusion()));
|
|
- public static final Block FLOWERING_AZALEA = register("flowering_azalea", new AzaleaBlock(BlockBehaviour.Properties.of(Material.PLANT).instabreak().sound(SoundType.FLOWERING_AZALEA).noOcclusion()));
|
|
+ public static final Block AZALEA = register("azalea", new AzaleaBlock(BlockBehaviour.Properties.of(Material.PLANT).randomTicks().instabreak().sound(SoundType.AZALEA).noOcclusion())); // Purpur
|
|
+ public static final Block FLOWERING_AZALEA = register("flowering_azalea", new AzaleaBlock(BlockBehaviour.Properties.of(Material.PLANT).randomTicks().instabreak().sound(SoundType.FLOWERING_AZALEA).noOcclusion())); // Purpur
|
|
public static final Block MOSS_CARPET = register("moss_carpet", new CarpetBlock(BlockBehaviour.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).strength(0.1F).sound(SoundType.MOSS_CARPET)));
|
|
public static final Block MOSS_BLOCK = register("moss_block", new MossBlock(BlockBehaviour.Properties.of(Material.MOSS, MaterialColor.COLOR_GREEN).strength(0.1F).sound(SoundType.MOSS)));
|
|
public static final Block BIG_DRIPLEAF = register("big_dripleaf", new BigDripleafBlock(BlockBehaviour.Properties.of(Material.PLANT).strength(0.1F).sound(SoundType.BIG_DRIPLEAF)));
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index 0ec0db28bf3fa246a5f57c8b36fd8a43e8a72cba..edb1390ae7f23d88ee8606dc93349488c694aa25 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -701,6 +701,11 @@ public class PurpurWorldConfig {
|
|
anvilAllowColors = getBoolean("blocks.anvil.allow-colors", anvilAllowColors);
|
|
}
|
|
|
|
+ public double azaleaGrowthChance = 0.0D;
|
|
+ private void azaleaSettings() {
|
|
+ azaleaGrowthChance = getDouble("blocks.azalea.growth-chance", azaleaGrowthChance);
|
|
+ }
|
|
+
|
|
public int beaconLevelOne = 20;
|
|
public int beaconLevelTwo = 30;
|
|
public int beaconLevelThree = 40;
|
|
@@ -830,6 +835,11 @@ public class PurpurWorldConfig {
|
|
farmlandTramplingFeatherFalling = getBoolean("blocks.farmland.feather-fall-distance-affects-trampling", farmlandTramplingFeatherFalling);
|
|
}
|
|
|
|
+ public double floweringAzaleaGrowthChance = 0.0D;
|
|
+ private void floweringAzaleaSettings() {
|
|
+ floweringAzaleaGrowthChance = getDouble("blocks.flowering_azalea.growth-chance", floweringAzaleaGrowthChance);
|
|
+ }
|
|
+
|
|
public boolean furnaceUseLavaFromUnderneath = false;
|
|
private void furnaceSettings() {
|
|
if (PurpurConfig.version < 17) {
|