mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 08:17:44 +01:00
Configurable cactus bamboo and reed growth height
Bamboo - Both the minimum fully-grown height and the maximum are configurable - Machine_Maker
This commit is contained in:
parent
a4d805a4be
commit
097b7fd752
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/level/block/BambooStalkBlock.java
|
--- a/net/minecraft/world/level/block/BambooStalkBlock.java
|
||||||
+++ b/net/minecraft/world/level/block/BambooStalkBlock.java
|
+++ b/net/minecraft/world/level/block/BambooStalkBlock.java
|
||||||
@@ -134,7 +134,7 @@
|
@@ -134,10 +134,10 @@
|
||||||
@Override
|
@Override
|
||||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||||
if ((Integer) state.getValue(BambooStalkBlock.STAGE) == 0) {
|
if ((Integer) state.getValue(BambooStalkBlock.STAGE) == 0) {
|
||||||
@ -8,13 +8,26 @@
|
|||||||
+ 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
|
+ 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
|
||||||
int i = this.getHeightBelowUpToMax(world, pos) + 1;
|
int i = this.getHeightBelowUpToMax(world, pos) + 1;
|
||||||
|
|
||||||
if (i < 16) {
|
- if (i < 16) {
|
||||||
|
+ if (i < world.paperConfig().maxGrowthHeight.bamboo.max) { // Paper - Configurable cactus/bamboo/reed growth height
|
||||||
|
this.growBamboo(state, world, pos, random, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -164,7 +164,7 @@
|
||||||
|
int i = this.getHeightAboveUpToMax(world, pos);
|
||||||
|
int j = this.getHeightBelowUpToMax(world, pos);
|
||||||
|
|
||||||
|
- return i + j + 1 < 16 && (Integer) world.getBlockState(pos.above(i)).getValue(BambooStalkBlock.STAGE) != 1;
|
||||||
|
+ 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
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -183,7 +183,7 @@
|
@@ -183,7 +183,7 @@
|
||||||
BlockPos blockposition1 = pos.above(i);
|
BlockPos blockposition1 = pos.above(i);
|
||||||
BlockState iblockdata1 = world.getBlockState(blockposition1);
|
BlockState iblockdata1 = world.getBlockState(blockposition1);
|
||||||
|
|
||||||
- if (k >= 16 || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) {
|
- if (k >= 16 || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) {
|
||||||
+ 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
|
+ 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
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,9 +52,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -222,7 +226,14 @@
|
@@ -220,15 +224,22 @@
|
||||||
|
}
|
||||||
|
|
||||||
int j = (Integer) state.getValue(BambooStalkBlock.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1;
|
int j = (Integer) state.getValue(BambooStalkBlock.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1;
|
||||||
int k = (height < 11 || random.nextFloat() >= 0.25F) && height != 15 ? 0 : 1;
|
- int k = (height < 11 || random.nextFloat() >= 0.25F) && height != 15 ? 0 : 1;
|
||||||
|
+ 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
|
||||||
|
|
||||||
- world.setBlock(pos.above(), (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, j)).setValue(BambooStalkBlock.LEAVES, blockpropertybamboosize)).setValue(BambooStalkBlock.STAGE, k), 3);
|
- world.setBlock(pos.above(), (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, j)).setValue(BambooStalkBlock.LEAVES, blockpropertybamboosize)).setValue(BambooStalkBlock.STAGE, k), 3);
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
@ -55,3 +71,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected int getHeightAboveUpToMax(BlockGetter world, BlockPos pos) {
|
protected int getHeightAboveUpToMax(BlockGetter world, BlockPos pos) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- for (i = 0; i < 16 && world.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) {
|
||||||
|
+ 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
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -238,7 +249,7 @@
|
||||||
|
protected int getHeightBelowUpToMax(BlockGetter world, BlockPos pos) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- for (i = 0; i < 16 && world.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) {
|
||||||
|
+ 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
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,12 @@
|
|||||||
|
|
||||||
public class CactusBlock extends Block {
|
public class CactusBlock extends Block {
|
||||||
|
|
||||||
@@ -64,13 +65,14 @@
|
@@ -61,16 +62,17 @@
|
||||||
if (i < 3) {
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (i < 3) {
|
||||||
|
+ if (i < world.paperConfig().maxGrowthHeight.cactus) { // Paper - Configurable cactus/bamboo/reed growth height
|
||||||
int j = (Integer) state.getValue(CactusBlock.AGE);
|
int j = (Integer) state.getValue(CactusBlock.AGE);
|
||||||
|
|
||||||
- if (j == 15) {
|
- if (j == 15) {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
--- a/net/minecraft/world/level/block/SugarCaneBlock.java
|
--- a/net/minecraft/world/level/block/SugarCaneBlock.java
|
||||||
+++ b/net/minecraft/world/level/block/SugarCaneBlock.java
|
+++ b/net/minecraft/world/level/block/SugarCaneBlock.java
|
||||||
@@ -62,10 +62,11 @@
|
@@ -59,13 +59,14 @@
|
||||||
if (i < 3) {
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (i < 3) {
|
||||||
|
+ if (i < world.paperConfig().maxGrowthHeight.reeds) { // Paper - Configurable cactus/bamboo/reed growth heigh
|
||||||
int j = (Integer) state.getValue(SugarCaneBlock.AGE);
|
int j = (Integer) state.getValue(SugarCaneBlock.AGE);
|
||||||
|
|
||||||
- if (j == 15) {
|
- if (j == 15) {
|
||||||
|
Loading…
Reference in New Issue
Block a user