3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00
Paper/patches/server/0027-Configurable-cactus-bamboo-and-reed-growth-height.patch

93 Zeilen
6.2 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 1 Mar 2016 13:02:51 -0600
2024-01-26 19:41:41 +01:00
Subject: [PATCH] Configurable cactus bamboo and reed growth height
2021-06-11 14:02:28 +02:00
2024-01-26 19:41:41 +01:00
Bamboo - Both the minimum fully-grown height and the maximum are configurable
2021-06-11 14:02:28 +02:00
- Machine_Maker
2022-12-07 19:32:25 +01:00
diff --git a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java
2024-10-22 19:28:57 +02:00
index 80bf98e7681cfde3a41ce5676425d5e96089500d..5e88bd02f5c53124f1aeec3eae727a1f83cc8238 100644
2022-12-07 19:32:25 +01:00
--- a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java
2023-12-05 20:39:26 +01:00
@@ -137,7 +137,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
if (random.nextFloat() < (world.spigotConfig.bambooModifier / (100.0f * 3)) && world.isEmptyBlock(pos.above()) && world.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution
2021-11-23 12:27:39 +01:00
int i = this.getHeightBelowUpToMax(world, pos) + 1;
2021-06-11 14:02:28 +02:00
- if (i < 16) {
2024-01-26 19:41:41 +01:00
+ if (i < world.paperConfig().maxGrowthHeight.bamboo.max) { // Paper - Configurable cactus/bamboo/reed growth height
2021-11-23 12:27:39 +01:00
this.growBamboo(state, world, pos, random, i);
2021-06-11 14:02:28 +02:00
}
}
2024-10-22 19:28:57 +02:00
@@ -164,7 +164,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
2021-06-11 14:02:28 +02:00
int i = this.getHeightAboveUpToMax(world, pos);
int j = this.getHeightBelowUpToMax(world, pos);
2022-12-07 19:32:25 +01:00
- return i + j + 1 < 16 && (Integer) world.getBlockState(pos.above(i)).getValue(BambooStalkBlock.STAGE) != 1;
2024-01-26 19:41:41 +01:00
+ return i + j + 1 < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && (Integer) world.getBlockState(pos.above(i)).getValue(BambooStalkBlock.STAGE) != 1; // Paper - Configurable cactus/bamboo/reed growth height
2021-06-11 14:02:28 +02:00
}
@Override
2024-10-22 19:28:57 +02:00
@@ -183,7 +183,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
2021-06-11 14:02:28 +02:00
BlockPos blockposition1 = pos.above(i);
BlockState iblockdata1 = world.getBlockState(blockposition1);
2022-12-07 19:32:25 +01:00
- if (k >= 16 || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here
2024-01-26 19:41:41 +01:00
+ if (k >= world.paperConfig().maxGrowthHeight.bamboo.max || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here // Paper - Configurable cactus/bamboo/reed growth height
2021-06-11 14:02:28 +02:00
return;
}
2024-10-22 19:28:57 +02:00
@@ -224,7 +224,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
2021-06-11 14:02:28 +02:00
}
2022-12-07 19:32:25 +01:00
int j = (Integer) state.getValue(BambooStalkBlock.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1;
2021-06-11 14:02:28 +02:00
- int k = (height < 11 || random.nextFloat() >= 0.25F) && height != 15 ? 0 : 1;
2024-01-26 19:41:41 +01:00
+ int k = (height < world.paperConfig().maxGrowthHeight.bamboo.min || random.nextFloat() >= 0.25F) && height != (world.paperConfig().maxGrowthHeight.bamboo.max - 1) ? 0 : 1; // Paper - Configurable cactus/bamboo/reed growth height
2021-06-11 14:02:28 +02:00
// CraftBukkit start
2022-12-07 19:32:25 +01:00
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, pos.above(), (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, j)).setValue(BambooStalkBlock.LEAVES, blockpropertybamboosize)).setValue(BambooStalkBlock.STAGE, k), 3)) {
2024-10-22 19:28:57 +02:00
@@ -239,7 +239,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
2021-06-11 14:02:28 +02:00
protected int getHeightAboveUpToMax(BlockGetter world, BlockPos pos) {
int i;
- for (i = 0; i < 16 && world.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) {
2024-01-26 19:41:41 +01:00
+ for (i = 0; i < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && world.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) { // Paper - Configurable cactus/bamboo/reed growth height
2021-06-11 14:02:28 +02:00
;
}
2024-10-22 19:28:57 +02:00
@@ -249,7 +249,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
2021-06-11 14:02:28 +02:00
protected int getHeightBelowUpToMax(BlockGetter world, BlockPos pos) {
int i;
- for (i = 0; i < 16 && world.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) {
2024-01-26 19:41:41 +01:00
+ for (i = 0; i < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && world.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) { // Paper - Configurable cactus/bamboo/reed growth height
2021-06-11 14:02:28 +02:00
;
}
diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
2024-10-22 19:28:57 +02:00
index de3df6606979171fd39fa6c5207fd9b0b668ba4e..de1b64e0cbe7f2de63f04262428c9e6ec340916e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
2024-10-22 19:28:57 +02:00
@@ -62,7 +62,7 @@ public class CactusBlock extends Block {
2021-06-11 14:02:28 +02:00
;
}
- if (i < 3) {
+ if (i < world.paperConfig().maxGrowthHeight.cactus) { // Paper - Configurable cactus/bamboo/reed growth height
2021-06-11 14:02:28 +02:00
int j = (Integer) state.getValue(CactusBlock.AGE);
int modifier = world.spigotConfig.cactusModifier; // Spigot - SPIGOT-7159: Better modifier resolution
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
2024-10-22 19:28:57 +02:00
index 161f70de43105c0b49b6c4d0a371dc6036c6813c..547ea09ed84595286c97c128b3b96f6d387ae25f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
2023-12-05 20:39:26 +01:00
@@ -59,7 +59,7 @@ public class SugarCaneBlock extends Block {
2021-06-11 14:02:28 +02:00
;
}
- if (i < 3) {
+ if (i < world.paperConfig().maxGrowthHeight.reeds) { // Paper - Configurable cactus/bamboo/reed growth heigh
2021-06-11 14:02:28 +02:00
int j = (Integer) state.getValue(SugarCaneBlock.AGE);
int modifier = world.spigotConfig.caneModifier; // Spigot - SPIGOT-7159: Better modifier resolution