2019-06-25 06:49:54 +10:00
|
|
|
From 093dc864636786070003fd287cd8f1afa1e68422 Mon Sep 17 00:00:00 2001
|
2016-03-07 22:16:12 +11:00
|
|
|
From: md_5 <git@md-5.net>
|
|
|
|
Date: Mon, 7 Mar 2016 22:14:13 +1100
|
2013-06-21 16:47:56 +10:00
|
|
|
Subject: [PATCH] Crop Growth Rates
|
2013-01-15 12:18:40 +11:00
|
|
|
|
2014-07-05 20:34:22 +10:00
|
|
|
Allows configuring the growth rates of crops as a percentage of their normal growth rate.
|
2013-01-15 12:18:40 +11:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
2019-06-21 20:00:00 +10:00
|
|
|
index 78f240154..b6318c503 100644
|
2013-01-15 12:18:40 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
2019-05-28 06:30:00 +10:00
|
|
|
@@ -698,6 +698,18 @@ public class Block implements IMaterial {
|
2013-01-15 12:18:40 +11:00
|
|
|
}
|
2019-04-23 12:00:00 +10:00
|
|
|
// CraftBukkit end
|
2016-11-17 12:41:12 +11:00
|
|
|
|
2013-01-15 12:18:40 +11:00
|
|
|
+ // 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
|
2016-11-17 12:41:12 +11:00
|
|
|
+
|
|
|
|
public static enum EnumRandomOffset {
|
|
|
|
|
|
|
|
NONE, XZ, XYZ;
|
2013-01-15 12:18:40 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java
|
2019-04-25 12:00:00 +10:00
|
|
|
index 0405815b8..a26e79412 100644
|
2013-01-15 12:18:40 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockCactus.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockCactus.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -33,7 +33,7 @@ public class BlockCactus extends Block {
|
2018-07-15 10:00:00 +10:00
|
|
|
if (i < 3) {
|
2018-12-06 10:00:00 +11:00
|
|
|
int j = (Integer) iblockdata.get(BlockCactus.AGE);
|
2014-11-26 08:27:08 +11:00
|
|
|
|
2018-07-15 10:00:00 +10:00
|
|
|
- if (j == 15) {
|
|
|
|
+ if (j >= (byte) range(3, ((100.0F / world.spigotConfig.cactusModifier) * 15) + 0.5F, 15)) { // Spigot
|
|
|
|
CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.getBlockData()); // CraftBukkit
|
2018-12-06 10:00:00 +11:00
|
|
|
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0);
|
2013-01-15 12:18:40 +11:00
|
|
|
|
2016-07-11 21:20:40 +10:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCocoa.java b/src/main/java/net/minecraft/server/BlockCocoa.java
|
2019-05-28 06:30:00 +10:00
|
|
|
index 769fe75b1..ee9f294f4 100644
|
2016-07-11 21:20:40 +10:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockCocoa.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockCocoa.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -20,7 +20,7 @@ public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePl
|
2018-07-15 10:00:00 +10:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
@Override
|
|
|
|
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
|
2018-07-15 10:00:00 +10:00
|
|
|
- if (world.random.nextInt(5) == 0) {
|
|
|
|
+ if (world.random.nextInt(Math.max(1, (int) (100.0F / world.spigotConfig.cocoaModifier) * 5)) == 0) { // Spigot
|
2018-12-06 10:00:00 +11:00
|
|
|
int i = (Integer) iblockdata.get(BlockCocoa.AGE);
|
2016-07-11 21:20:40 +10:00
|
|
|
|
|
|
|
if (i < 2) {
|
2013-01-15 12:18:40 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java
|
2019-06-21 20:00:00 +10:00
|
|
|
index 40e2da9e2..9b0c8cd0f 100644
|
2013-01-15 12:18:40 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockCrops.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockCrops.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -53,7 +53,20 @@ public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement
|
2018-07-22 12:00:00 +10:00
|
|
|
if (i < this.e()) {
|
2018-07-15 10:00:00 +10:00
|
|
|
float f = a((Block) this, (IBlockAccess) world, blockposition);
|
2013-01-15 12:18:40 +11:00
|
|
|
|
|
|
|
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
2018-12-27 10:53:44 +11:00
|
|
|
+ // 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.nextInt((int) ((100.0F / modifier) * (25.0F / f)) + 1) == 0) {
|
|
|
|
+ // Spigot end
|
2018-07-15 10:00:00 +10:00
|
|
|
CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i + 1), 2); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
2013-01-15 12:18:40 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java
|
2019-05-14 10:00:00 +10:00
|
|
|
index f47912c48..9a260cbaa 100644
|
2013-01-15 12:18:40 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockMushroom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockMushroom.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -22,7 +22,7 @@ public class BlockMushroom extends BlockPlant implements IBlockFragilePlantEleme
|
2013-01-15 12:18:40 +11:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
@Override
|
|
|
|
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
|
2013-01-15 12:18:40 +11:00
|
|
|
- if (random.nextInt(25) == 0) {
|
2016-03-26 09:05:21 +11:00
|
|
|
+ if (random.nextInt(Math.max(1, (int) (100.0F / world.spigotConfig.mushroomModifier) * 25)) == 0) { // Spigot
|
2014-11-26 08:27:08 +11:00
|
|
|
int i = 5;
|
|
|
|
boolean flag = true;
|
2019-04-23 12:00:00 +10:00
|
|
|
Iterator iterator = BlockPosition.a(blockposition.b(-4, -1, -4), blockposition.b(4, 1, 4)).iterator();
|
2015-05-26 19:13:21 +10:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockNetherWart.java b/src/main/java/net/minecraft/server/BlockNetherWart.java
|
2019-05-28 06:30:00 +10:00
|
|
|
index f009429d8..fbd242eb6 100644
|
2015-05-26 19:13:21 +10:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockNetherWart.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockNetherWart.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -26,7 +26,7 @@ public class BlockNetherWart extends BlockPlant {
|
|
|
|
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
|
2018-12-06 10:00:00 +11:00
|
|
|
int i = (Integer) iblockdata.get(BlockNetherWart.AGE);
|
2015-05-26 19:13:21 +10:00
|
|
|
|
|
|
|
- if (i < 3 && random.nextInt(10) == 0) {
|
2016-03-26 09:05:21 +11:00
|
|
|
+ if (i < 3 && random.nextInt(Math.max(1, (int) (100.0F / world.spigotConfig.wartModifier) * 10)) == 0) { // Spigot
|
2018-12-06 10:00:00 +11:00
|
|
|
iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1);
|
2018-07-15 10:00:00 +10:00
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit
|
|
|
|
}
|
2013-01-15 12:18:40 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java
|
2019-04-25 12:00:00 +10:00
|
|
|
index 8151db501..4d5f485f0 100644
|
2013-01-15 12:18:40 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockReed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockReed.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -32,7 +32,7 @@ public class BlockReed extends Block {
|
2018-07-15 10:00:00 +10:00
|
|
|
if (i < 3) {
|
2018-12-06 10:00:00 +11:00
|
|
|
int j = (Integer) iblockdata.get(BlockReed.AGE);
|
2013-01-15 12:18:40 +11:00
|
|
|
|
2018-07-15 10:00:00 +10:00
|
|
|
- if (j == 15) {
|
|
|
|
+ if (j >= (byte) range(3, ((100.0F / world.spigotConfig.caneModifier) * 15) + 0.5F, 15)) { // Spigot
|
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.up(), this.getBlockData()); // CraftBukkit
|
2018-12-06 10:00:00 +11:00
|
|
|
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, 0), 4);
|
2018-07-15 10:00:00 +10:00
|
|
|
} else {
|
2013-01-15 12:18:40 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java
|
2019-04-25 12:00:00 +10:00
|
|
|
index b63038734..28517b63f 100644
|
2013-01-15 12:18:40 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockSapling.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockSapling.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -32,7 +32,7 @@ public class BlockSapling extends BlockPlant implements IBlockFragilePlantElemen
|
|
|
|
@Override
|
|
|
|
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
|
|
|
|
super.tick(iblockdata, world, blockposition, random);
|
2018-07-15 10:00:00 +10:00
|
|
|
- if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
|
|
|
|
+ if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(Math.max(2, (int) (((100.0F / world.spigotConfig.saplingModifier) * 7) + 0.5F))) == 0) { // Spigot
|
|
|
|
// CraftBukkit start
|
|
|
|
world.captureTreeGeneration = true;
|
|
|
|
// CraftBukkit end
|
2013-01-15 12:18:40 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java
|
2019-05-28 06:30:00 +10:00
|
|
|
index 5f2077664..f67b0c3ef 100644
|
2013-01-15 12:18:40 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockStem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockStem.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -32,7 +32,7 @@ public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
|
|
|
|
if (world.getLightLevel(blockposition, 0) >= 9) {
|
2018-07-15 10:00:00 +10:00
|
|
|
float f = BlockCrops.a((Block) this, (IBlockAccess) world, blockposition);
|
2013-01-15 12:18:40 +11:00
|
|
|
|
|
|
|
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
2016-03-26 09:05:21 +11:00
|
|
|
+ if (random.nextInt((int) ((100.0F / (this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier)) * (25.0F / f)) + 1) == 0) { // Spigot
|
2018-12-06 10:00:00 +11:00
|
|
|
int i = (Integer) iblockdata.get(BlockStem.AGE);
|
2013-01-15 12:18:40 +11:00
|
|
|
|
2014-11-26 08:27:08 +11:00
|
|
|
if (i < 7) {
|
2016-07-11 21:20:40 +10:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockVine.java b/src/main/java/net/minecraft/server/BlockVine.java
|
2019-05-28 06:30:00 +10:00
|
|
|
index baaa87b94..455dae92a 100644
|
2016-07-11 21:20:40 +10:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockVine.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockVine.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -161,7 +161,7 @@ public class BlockVine extends Block {
|
|
|
|
world.a(blockposition, false);
|
2018-07-15 10:00:00 +10:00
|
|
|
}
|
2016-07-11 21:20:40 +10:00
|
|
|
|
2018-07-15 10:00:00 +10:00
|
|
|
- } else if (world.random.nextInt(4) == 0) {
|
|
|
|
+ } else if (world.random.nextInt(Math.max(1, (int) (100.0F / world.spigotConfig.vineModifier) * 4)) == 0) { // Spigot
|
|
|
|
EnumDirection enumdirection = EnumDirection.a(random);
|
|
|
|
BlockPosition blockposition1 = blockposition.up();
|
|
|
|
BlockPosition blockposition2;
|
2013-06-20 18:21:31 +10:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2019-04-30 12:16:33 +10:00
|
|
|
index 9b3d0bcd6..a7a71fec0 100644
|
2013-06-20 18:21:31 +10:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2019-04-30 12:16:33 +10:00
|
|
|
@@ -73,4 +73,47 @@ public class SpigotWorldConfig
|
2016-03-01 08:33:06 +11:00
|
|
|
config.addDefault( "world-settings.default." + path, def );
|
|
|
|
return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
|
2013-06-20 18:21:31 +10:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Crop growth rates
|
2013-06-21 17:00:01 +10:00
|
|
|
+ public int cactusModifier;
|
|
|
|
+ public int caneModifier;
|
|
|
|
+ public int melonModifier;
|
|
|
|
+ public int mushroomModifier;
|
|
|
|
+ public int pumpkinModifier;
|
|
|
|
+ public int saplingModifier;
|
2018-12-27 10:53:44 +11:00
|
|
|
+ public int beetrootModifier;
|
|
|
|
+ public int carrotModifier;
|
|
|
|
+ public int potatoModifier;
|
2013-06-21 17:00:01 +10:00
|
|
|
+ public int wheatModifier;
|
2015-05-26 08:35:03 +01:00
|
|
|
+ public int wartModifier;
|
2016-07-11 21:20:40 +10:00
|
|
|
+ public int vineModifier;
|
|
|
|
+ public int cocoaModifier;
|
2013-12-03 09:05:49 +11:00
|
|
|
+ private int getAndValidateGrowth(String crop)
|
2013-06-20 18:21:31 +10:00
|
|
|
+ {
|
2016-06-26 19:36:08 +10:00
|
|
|
+ int modifier = getInt( "growth." + crop.toLowerCase(java.util.Locale.ENGLISH) + "-modifier", 100 );
|
2013-12-03 09:05:49 +11:00
|
|
|
+ if ( modifier == 0 )
|
|
|
|
+ {
|
|
|
|
+ log( "Cannot set " + crop + " growth to zero, defaulting to 100" );
|
|
|
|
+ modifier = 100;
|
|
|
|
+ }
|
|
|
|
+ log( crop + " Growth Modifier: " + modifier + "%" );
|
2013-06-20 18:21:31 +10:00
|
|
|
+
|
2013-12-03 09:05:49 +11:00
|
|
|
+ return modifier;
|
|
|
|
+ }
|
|
|
|
+ private void growthModifiers()
|
|
|
|
+ {
|
|
|
|
+ cactusModifier = getAndValidateGrowth( "Cactus" );
|
|
|
|
+ caneModifier = getAndValidateGrowth( "Cane" );
|
|
|
|
+ melonModifier = getAndValidateGrowth( "Melon" );
|
|
|
|
+ mushroomModifier = getAndValidateGrowth( "Mushroom" );
|
|
|
|
+ pumpkinModifier = getAndValidateGrowth( "Pumpkin" );
|
|
|
|
+ saplingModifier = getAndValidateGrowth( "Sapling" );
|
2018-12-27 10:53:44 +11:00
|
|
|
+ beetrootModifier = getAndValidateGrowth( "Beetroot" );
|
|
|
|
+ carrotModifier = getAndValidateGrowth( "Carrot" );
|
|
|
|
+ potatoModifier = getAndValidateGrowth( "Potato" );
|
2013-12-03 09:05:49 +11:00
|
|
|
+ wheatModifier = getAndValidateGrowth( "Wheat" );
|
2015-05-26 08:35:03 +01:00
|
|
|
+ wartModifier = getAndValidateGrowth( "NetherWart" );
|
2016-07-11 21:20:40 +10:00
|
|
|
+ vineModifier = getAndValidateGrowth( "Vine" );
|
|
|
|
+ cocoaModifier = getAndValidateGrowth( "Cocoa" );
|
2013-06-20 18:21:31 +10:00
|
|
|
+ }
|
|
|
|
}
|
2013-01-15 12:18:40 +11:00
|
|
|
--
|
2019-04-23 09:33:25 +10:00
|
|
|
2.20.1
|
2013-01-15 12:18:40 +11:00
|
|
|
|