geforkt von Mirrors/Paper
Crop Growth Rates
Allows configuring the growth rates of crops as a percentage of their normal growth rate. By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
cba0d1f1ec
Commit
df403168ff
@ -1,5 +1,14 @@
|
||||
--- a/net/minecraft/world/level/block/BambooSaplingBlock.java
|
||||
+++ b/net/minecraft/world/level/block/BambooSaplingBlock.java
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
@Override
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
- if (random.nextInt(3) == 0 && world.isEmptyBlock(pos.above()) && world.getRawBrightness(pos.above(), 0) >= 9) {
|
||||
+ 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
|
||||
this.growBamboo(world, pos);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,6 @@
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,14 @@
|
||||
--- a/net/minecraft/world/level/block/BambooStalkBlock.java
|
||||
+++ b/net/minecraft/world/level/block/BambooStalkBlock.java
|
||||
@@ -134,7 +134,7 @@
|
||||
@Override
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
if ((Integer) state.getValue(BambooStalkBlock.STAGE) == 0) {
|
||||
- if (random.nextInt(3) == 0 && world.isEmptyBlock(pos.above()) && world.getRawBrightness(pos.above(), 0) >= 9) {
|
||||
+ 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;
|
||||
|
||||
if (i < 16) {
|
||||
@@ -183,7 +183,7 @@
|
||||
BlockPos blockposition1 = pos.above(i);
|
||||
BlockState iblockdata1 = world.getBlockState(blockposition1);
|
||||
|
@ -24,7 +24,7 @@
|
||||
Block.dropResources(state, world, pos, blockEntity, player, tool);
|
||||
}
|
||||
|
||||
@@ -490,15 +496,23 @@
|
||||
@@ -490,15 +496,35 @@
|
||||
return this.builtInRegistryHolder;
|
||||
}
|
||||
|
||||
@ -47,6 +47,18 @@
|
||||
+ return 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // Spigot start
|
||||
+ public static float range(float min, float value, float max) {
|
||||
+ if (value < min) {
|
||||
+ return min;
|
||||
+ }
|
||||
+ if (value > max) {
|
||||
+ return max;
|
||||
+ }
|
||||
+ return value;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
private static record ShapePairKey(VoxelShape first, VoxelShape second) {
|
||||
|
||||
|
@ -8,16 +8,25 @@
|
||||
|
||||
public class CactusBlock extends Block {
|
||||
|
||||
@@ -65,7 +66,7 @@
|
||||
@@ -64,13 +65,14 @@
|
||||
if (i < 3) {
|
||||
int j = (Integer) state.getValue(CactusBlock.AGE);
|
||||
|
||||
if (j == 15) {
|
||||
- if (j == 15) {
|
||||
- world.setBlockAndUpdate(blockposition1, this.defaultBlockState());
|
||||
+ int modifier = world.spigotConfig.cactusModifier; // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
+ if (j >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.defaultBlockState()); // CraftBukkit
|
||||
BlockState iblockdata1 = (BlockState) state.setValue(CactusBlock.AGE, 0);
|
||||
|
||||
world.setBlock(pos, iblockdata1, 4);
|
||||
@@ -120,7 +121,7 @@
|
||||
world.neighborChanged(iblockdata1, blockposition1, this, (Orientation) null, false);
|
||||
- } else {
|
||||
+ } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
world.setBlock(pos, (BlockState) state.setValue(CactusBlock.AGE, j + 1), 4);
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@
|
||||
|
||||
@Override
|
||||
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
|
@ -8,7 +8,12 @@
|
||||
|
||||
public class CocoaBlock extends HorizontalDirectionalBlock implements BonemealableBlock {
|
||||
|
||||
@@ -61,7 +62,7 @@
|
||||
@@ -57,11 +58,11 @@
|
||||
|
||||
@Override
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
- if (world.random.nextInt(5) == 0) {
|
||||
+ if (world.random.nextFloat() < (world.spigotConfig.cocoaModifier / (100.0f * 5))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
int i = (Integer) state.getValue(CocoaBlock.AGE);
|
||||
|
||||
if (i < 2) {
|
||||
|
@ -8,16 +8,32 @@
|
||||
|
||||
public class CropBlock extends BushBlock implements BonemealableBlock {
|
||||
|
||||
@@ -83,7 +84,7 @@
|
||||
@@ -82,9 +83,22 @@
|
||||
if (i < this.getMaxAge()) {
|
||||
float f = CropBlock.getGrowthSpeed(this, world, pos);
|
||||
|
||||
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
||||
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
||||
- world.setBlock(pos, this.getStateForAge(i + 1), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(i + 1), 2); // CraftBukkit
|
||||
+ // Spigot start
|
||||
+ int modifier;
|
||||
+ if (this == Blocks.BEETROOTS) {
|
||||
+ modifier = world.spigotConfig.beetrootModifier;
|
||||
+ } else if (this == Blocks.CARROTS) {
|
||||
+ modifier = world.spigotConfig.carrotModifier;
|
||||
+ } else if (this == Blocks.POTATOES) {
|
||||
+ modifier = world.spigotConfig.potatoModifier;
|
||||
+ } else {
|
||||
+ modifier = world.spigotConfig.wheatModifier;
|
||||
}
|
||||
+
|
||||
+ if (random.nextFloat() < (modifier / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
+ // Spigot end
|
||||
+ CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(i + 1), 2); // CraftBukkit
|
||||
+ }
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@
|
||||
|
||||
@@ -98,7 +112,7 @@
|
||||
i = j;
|
||||
}
|
||||
|
||||
@ -26,7 +42,7 @@
|
||||
}
|
||||
|
||||
protected int getBonemealAgeIncrease(Level world) {
|
||||
@@ -161,7 +162,7 @@
|
||||
@@ -161,7 +175,7 @@
|
||||
@Override
|
||||
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
|
@ -1,6 +1,23 @@
|
||||
--- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
|
||||
+++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
|
||||
@@ -48,7 +48,7 @@
|
||||
@@ -44,11 +44,23 @@
|
||||
|
||||
@Override
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
- if ((Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25 && random.nextDouble() < this.growPerTickProbability) {
|
||||
+ // Spigot start
|
||||
+ int modifier;
|
||||
+ if (this == Blocks.KELP) {
|
||||
+ modifier = world.spigotConfig.kelpModifier;
|
||||
+ } else if (this == Blocks.TWISTING_VINES) {
|
||||
+ modifier = world.spigotConfig.twistingVinesModifier;
|
||||
+ } else if (this == Blocks.WEEPING_VINES) {
|
||||
+ modifier = world.spigotConfig.weepingVinesModifier;
|
||||
+ } else {
|
||||
+ modifier = world.spigotConfig.caveVinesModifier;
|
||||
+ }
|
||||
+ if ((Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25 && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
+ // Spigot end
|
||||
BlockPos blockposition1 = pos.relative(this.growthDirection);
|
||||
|
||||
if (this.canGrowInto(world.getBlockState(blockposition1))) {
|
||||
|
@ -10,6 +10,15 @@
|
||||
|
||||
public class MushroomBlock extends BushBlock implements BonemealableBlock {
|
||||
|
||||
@@ -48,7 +51,7 @@
|
||||
|
||||
@Override
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
- if (random.nextInt(25) == 0) {
|
||||
+ if (random.nextFloat() < (world.spigotConfig.mushroomModifier / (100.0f * 25))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
int i = 5;
|
||||
boolean flag = true;
|
||||
Iterator iterator = BlockPos.betweenClosed(pos.offset(-4, -1, -4), pos.offset(4, 1, 4)).iterator();
|
||||
@@ -75,7 +78,7 @@
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
--- a/net/minecraft/world/level/block/NetherWartBlock.java
|
||||
+++ b/net/minecraft/world/level/block/NetherWartBlock.java
|
||||
@@ -54,7 +54,7 @@
|
||||
@@ -52,9 +52,9 @@
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
int i = (Integer) state.getValue(NetherWartBlock.AGE);
|
||||
|
||||
if (i < 3 && random.nextInt(10) == 0) {
|
||||
- if (i < 3 && random.nextInt(10) == 0) {
|
||||
+ if (i < 3 && random.nextFloat() < (world.spigotConfig.wartModifier / (100.0f * 10))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
state = (BlockState) state.setValue(NetherWartBlock.AGE, i + 1);
|
||||
- world.setBlock(pos, state, 2);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, pos, state, 2); // CraftBukkit
|
||||
|
@ -45,8 +45,9 @@
|
||||
|
||||
@Override
|
||||
- protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
- if (world.getMaxLocalRawBrightness(pos.above()) >= 9 && random.nextInt(7) == 0) {
|
||||
+ protected void randomTick(net.minecraft.world.level.block.state.BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
if (world.getMaxLocalRawBrightness(pos.above()) >= 9 && random.nextInt(7) == 0) {
|
||||
+ if (world.getMaxLocalRawBrightness(pos.above()) >= 9 && random.nextFloat() < (world.spigotConfig.saplingModifier / (100.0f * 7))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
this.advanceTree(world, pos, state, random);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,13 @@
|
||||
|
||||
public class StemBlock extends BushBlock implements BonemealableBlock {
|
||||
|
||||
@@ -79,7 +80,7 @@
|
||||
@@ -74,12 +75,12 @@
|
||||
if (world.getRawBrightness(pos, 0) >= 9) {
|
||||
float f = CropBlock.getGrowthSpeed(this, world, pos);
|
||||
|
||||
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
||||
+ if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
int i = (Integer) state.getValue(StemBlock.AGE);
|
||||
|
||||
if (i < 7) {
|
||||
state = (BlockState) state.setValue(StemBlock.AGE, i + 1);
|
||||
|
@ -1,11 +1,17 @@
|
||||
--- a/net/minecraft/world/level/block/SugarCaneBlock.java
|
||||
+++ b/net/minecraft/world/level/block/SugarCaneBlock.java
|
||||
@@ -63,7 +63,7 @@
|
||||
@@ -62,10 +62,11 @@
|
||||
if (i < 3) {
|
||||
int j = (Integer) state.getValue(SugarCaneBlock.AGE);
|
||||
|
||||
if (j == 15) {
|
||||
- if (j == 15) {
|
||||
- world.setBlockAndUpdate(pos.above(), this.defaultBlockState());
|
||||
+ int modifier = world.spigotConfig.caneModifier; // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
+ if (j >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, pos.above(), this.defaultBlockState()); // CraftBukkit
|
||||
world.setBlock(pos, (BlockState) state.setValue(SugarCaneBlock.AGE, 0), 4);
|
||||
} else {
|
||||
- } else {
|
||||
+ } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
world.setBlock(pos, (BlockState) state.setValue(SugarCaneBlock.AGE, j + 1), 4);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,12 @@
|
||||
|
||||
public class SweetBerryBushBlock extends BushBlock implements BonemealableBlock {
|
||||
|
||||
@@ -70,7 +76,7 @@
|
||||
if (i < 3 && random.nextInt(5) == 0 && world.getRawBrightness(pos.above(), 0) >= 9) {
|
||||
@@ -67,10 +73,10 @@
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
int i = (Integer) state.getValue(SweetBerryBushBlock.AGE);
|
||||
|
||||
- if (i < 3 && random.nextInt(5) == 0 && world.getRawBrightness(pos.above(), 0) >= 9) {
|
||||
+ if (i < 3 && random.nextFloat() < (world.spigotConfig.sweetBerryModifier / (100.0f * 5)) && world.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
BlockState iblockdata1 = (BlockState) state.setValue(SweetBerryBushBlock.AGE, i + 1);
|
||||
|
||||
- world.setBlock(pos, iblockdata1, 2);
|
||||
|
@ -8,6 +8,15 @@
|
||||
|
||||
public class VineBlock extends Block {
|
||||
|
||||
@@ -184,7 +185,7 @@
|
||||
@Override
|
||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
if (world.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) {
|
||||
- if (random.nextInt(4) == 0) {
|
||||
+ if (random.nextFloat() < (world.spigotConfig.vineModifier / (100.0f * 4))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
Direction enumdirection = Direction.getRandom(random);
|
||||
BlockPos blockposition1 = pos.above();
|
||||
BlockPos blockposition2;
|
||||
@@ -203,30 +204,34 @@
|
||||
BlockPos blockposition3 = blockposition2.relative(enumdirection1);
|
||||
BlockPos blockposition4 = blockposition2.relative(enumdirection2);
|
||||
@ -29,10 +38,9 @@
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition3, (BlockState) this.defaultBlockState().setValue(VineBlock.getPropertyForFace(enumdirection3), true), 2);
|
||||
} else if (flag1 && world.isEmptyBlock(blockposition4) && VineBlock.isAcceptableNeighbour(world, pos.relative(enumdirection2), enumdirection3)) {
|
||||
- world.setBlock(blockposition4, (BlockState) this.defaultBlockState().setValue(VineBlock.getPropertyForFace(enumdirection3), true), 2);
|
||||
- } else if ((double) random.nextFloat() < 0.05D && VineBlock.isAcceptableNeighbour(world, blockposition2.above(), Direction.UP)) {
|
||||
- world.setBlock(blockposition2, (BlockState) this.defaultBlockState().setValue(VineBlock.UP, true), 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition4, (BlockState) this.defaultBlockState().setValue(VineBlock.getPropertyForFace(enumdirection3), true), 2);
|
||||
+ } else if ((double) random.nextFloat() < 0.05D && VineBlock.isAcceptableNeighbour(world, blockposition2.above(), Direction.UP)) {
|
||||
} else if ((double) random.nextFloat() < 0.05D && VineBlock.isAcceptableNeighbour(world, blockposition2.above(), Direction.UP)) {
|
||||
- world.setBlock(blockposition2, (BlockState) this.defaultBlockState().setValue(VineBlock.UP, true), 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (BlockState) this.defaultBlockState().setValue(VineBlock.UP, true), 2);
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
@ -79,4 +79,59 @@ public class SpigotWorldConfig
|
||||
this.config.addDefault( "world-settings.default." + path, def );
|
||||
return this.config.get( "world-settings." + this.worldName + "." + path, this.config.get( "world-settings.default." + path ) );
|
||||
}
|
||||
|
||||
// Crop growth rates
|
||||
public int cactusModifier;
|
||||
public int caneModifier;
|
||||
public int melonModifier;
|
||||
public int mushroomModifier;
|
||||
public int pumpkinModifier;
|
||||
public int saplingModifier;
|
||||
public int beetrootModifier;
|
||||
public int carrotModifier;
|
||||
public int potatoModifier;
|
||||
public int wheatModifier;
|
||||
public int wartModifier;
|
||||
public int vineModifier;
|
||||
public int cocoaModifier;
|
||||
public int bambooModifier;
|
||||
public int sweetBerryModifier;
|
||||
public int kelpModifier;
|
||||
public int twistingVinesModifier;
|
||||
public int weepingVinesModifier;
|
||||
public int caveVinesModifier;
|
||||
private int getAndValidateGrowth(String crop)
|
||||
{
|
||||
int modifier = this.getInt( "growth." + crop.toLowerCase(java.util.Locale.ENGLISH) + "-modifier", 100 );
|
||||
if ( modifier == 0 )
|
||||
{
|
||||
this.log( "Cannot set " + crop + " growth to zero, defaulting to 100" );
|
||||
modifier = 100;
|
||||
}
|
||||
this.log( crop + " Growth Modifier: " + modifier + "%" );
|
||||
|
||||
return modifier;
|
||||
}
|
||||
private void growthModifiers()
|
||||
{
|
||||
this.cactusModifier = this.getAndValidateGrowth( "Cactus" );
|
||||
this.caneModifier = this.getAndValidateGrowth( "Cane" );
|
||||
this.melonModifier = this.getAndValidateGrowth( "Melon" );
|
||||
this.mushroomModifier = this.getAndValidateGrowth( "Mushroom" );
|
||||
this.pumpkinModifier = this.getAndValidateGrowth( "Pumpkin" );
|
||||
this.saplingModifier = this.getAndValidateGrowth( "Sapling" );
|
||||
this.beetrootModifier = this.getAndValidateGrowth( "Beetroot" );
|
||||
this.carrotModifier = this.getAndValidateGrowth( "Carrot" );
|
||||
this.potatoModifier = this.getAndValidateGrowth( "Potato" );
|
||||
this.wheatModifier = this.getAndValidateGrowth( "Wheat" );
|
||||
this.wartModifier = this.getAndValidateGrowth( "NetherWart" );
|
||||
this.vineModifier = this.getAndValidateGrowth( "Vine" );
|
||||
this.cocoaModifier = this.getAndValidateGrowth( "Cocoa" );
|
||||
this.bambooModifier = this.getAndValidateGrowth( "Bamboo" );
|
||||
this.sweetBerryModifier = this.getAndValidateGrowth( "SweetBerry" );
|
||||
this.kelpModifier = this.getAndValidateGrowth( "Kelp" );
|
||||
this.twistingVinesModifier = this.getAndValidateGrowth( "TwistingVines" );
|
||||
this.weepingVinesModifier = this.getAndValidateGrowth( "WeepingVines" );
|
||||
this.caveVinesModifier = this.getAndValidateGrowth( "CaveVines" );
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren