2016-02-29 21:33:06 +00:00
|
|
|
From 0f544805062834e55ff56f0cde813c693dbcc85d Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
From: md_5 <md_5@live.com.au>
|
|
|
|
Date: Fri, 21 Jun 2013 17:17:20 +1000
|
|
|
|
Subject: [PATCH] Crop Growth Rates
|
|
|
|
|
|
|
|
Allows configuring the growth rates of crops as a percentage of their normal growth rate.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 57f3981..12589d6 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -857,4 +857,16 @@ public class Block {
|
|
|
|
private static void a(int i, String s, Block block) {
|
|
|
|
a(i, new MinecraftKey(s), block);
|
2014-07-21 20:46:54 +00: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
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index f4b90e1..862075d 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockCactus.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockCactus.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -31,7 +31,7 @@ public class BlockCactus extends Block {
|
2014-11-28 01:17:45 +00:00
|
|
|
if (i < 3) {
|
|
|
|
int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue();
|
|
|
|
|
|
|
|
- if (j == 15) {
|
2016-02-29 21:33:06 +00:00
|
|
|
+ if (j >= (byte) range(3, (world.spigotConfig.cactusModifier / 100 * 15) + 0.5F, 15)) { // Spigot
|
2014-12-11 04:21:51 +00:00
|
|
|
// world.setTypeUpdate(blockposition1, this.getBlockData()); // CraftBukkit
|
2014-11-28 01:17:45 +00:00
|
|
|
IBlockData iblockdata1 = iblockdata.set(BlockCactus.AGE, Integer.valueOf(0));
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 062f769..d545d1a 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockCrops.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockCrops.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -54,7 +54,7 @@ public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement
|
|
|
|
if (i < this.g()) {
|
2014-11-28 01:17:45 +00:00
|
|
|
float f = a((Block) this, world, blockposition);
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
2016-02-29 21:33:06 +00:00
|
|
|
+ if (random.nextInt((int) (world.spigotConfig.wheatModifier / 100 * (25.0F / f)) + 1) == 0) { // Spigot // CraftBukkit start
|
|
|
|
// CraftBukkit start
|
|
|
|
IBlockData data = this.setAge(i + 1);
|
2015-02-28 11:36:22 +00:00
|
|
|
CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index fa7919e..e069252 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockMushroom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockMushroom.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -23,7 +23,7 @@ public class BlockMushroom extends BlockPlant implements IBlockFragilePlantEleme
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
|
|
|
final int sourceX = blockposition.getX(), sourceY = blockposition.getY(), sourceZ = blockposition.getZ(); // CraftBukkit
|
2014-07-21 20:46:54 +00:00
|
|
|
- if (random.nextInt(25) == 0) {
|
2016-02-29 21:33:06 +00:00
|
|
|
+ if (random.nextInt(Math.max(1, (int) world.spigotConfig.mushroomModifier / 100 * 25)) == 0) { // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
int i = 5;
|
|
|
|
boolean flag = true;
|
|
|
|
Iterator iterator = BlockPosition.b(blockposition.a(-4, -1, -4), blockposition.a(4, 1, 4)).iterator();
|
2015-05-26 09:13:21 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockNetherWart.java b/src/main/java/net/minecraft/server/BlockNetherWart.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index b2ca55f..9cd8bd8 100644
|
2015-05-26 09:13:21 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockNetherWart.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockNetherWart.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -29,7 +29,7 @@ public class BlockNetherWart extends BlockPlant {
|
2015-05-26 09:13:21 +00:00
|
|
|
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
|
|
|
int i = ((Integer) iblockdata.get(BlockNetherWart.AGE)).intValue();
|
|
|
|
|
|
|
|
- if (i < 3 && random.nextInt(10) == 0) {
|
2016-02-29 21:33:06 +00:00
|
|
|
+ if (i < 3 && random.nextInt(Math.max(1, (int) world.spigotConfig.wartModifier / 100 * 10)) == 0) { // Spigot
|
2015-05-26 09:13:21 +00:00
|
|
|
iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1));
|
|
|
|
// world.setTypeAndData(blockposition, iblockdata, 2); // CraftBukkit
|
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); // CraftBukkit
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index f507b83..b8c36a7 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockReed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockReed.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -30,7 +30,7 @@ public class BlockReed extends Block {
|
2014-11-28 01:17:45 +00:00
|
|
|
if (i < 3) {
|
|
|
|
int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
- if (j == 15) {
|
2016-02-29 21:33:06 +00:00
|
|
|
+ if (j >= (byte) range(3, (world.spigotConfig.caneModifier /100 * 15) + 0.5F, 15)) { // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
// CraftBukkit start
|
2014-12-11 04:21:51 +00:00
|
|
|
// world.setTypeUpdate(blockposition.up(), this.getBlockData()); // CraftBukkit
|
|
|
|
BlockPosition upPos = blockposition.up();
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index a2691a5..a60a7f8 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockSapling.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockSapling.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -34,7 +34,7 @@ public class BlockSapling extends BlockPlant implements IBlockFragilePlantElemen
|
2014-11-28 01:17:45 +00:00
|
|
|
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
2015-02-28 11:36:22 +00:00
|
|
|
if (!world.isClientSide) {
|
2014-11-28 01:17:45 +00:00
|
|
|
super.b(world, blockposition, iblockdata, random);
|
|
|
|
- if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
|
2016-02-29 21:33:06 +00:00
|
|
|
+ if (world.getLightLevel(blockposition.up()) >= 9 && (random.nextInt(Math.max(2, (int) ((world.spigotConfig.saplingModifier / 100 * 7) + 0.5F))) == 0)) { // Spigot) {
|
2014-07-21 20:46:54 +00:00
|
|
|
// CraftBukkit start
|
|
|
|
world.captureTreeGeneration = true;
|
|
|
|
// CraftBukkit end
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 41200fa..53d99aa 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockStem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockStem.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -50,7 +50,7 @@ public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
|
2014-11-28 01:17:45 +00:00
|
|
|
if (world.getLightLevel(blockposition.up()) >= 9) {
|
|
|
|
float f = BlockCrops.a((Block) this, world, blockposition);
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
2016-02-29 21:33:06 +00:00
|
|
|
+ if (random.nextInt((int) ((this == Blocks.PUMPKIN_STEM? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) / 100 * (25.0F / f)) + 1) == 0) { // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue();
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
if (i < 7) {
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 961ddb4..8860a96 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -68,4 +68,37 @@ public class SpigotWorldConfig
|
|
|
|
config.addDefault( "world-settings.default." + path, def );
|
|
|
|
return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Crop growth rates
|
|
|
|
+ public int cactusModifier;
|
|
|
|
+ public int caneModifier;
|
|
|
|
+ public int melonModifier;
|
|
|
|
+ public int mushroomModifier;
|
|
|
|
+ public int pumpkinModifier;
|
|
|
|
+ public int saplingModifier;
|
|
|
|
+ public int wheatModifier;
|
2015-05-26 07:35:03 +00:00
|
|
|
+ public int wartModifier;
|
2014-07-21 20:46:54 +00:00
|
|
|
+ private int getAndValidateGrowth(String crop)
|
|
|
|
+ {
|
|
|
|
+ int modifier = getInt( "growth." + crop.toLowerCase() + "-modifier", 100 );
|
|
|
|
+ if ( modifier == 0 )
|
|
|
|
+ {
|
|
|
|
+ log( "Cannot set " + crop + " growth to zero, defaulting to 100" );
|
|
|
|
+ modifier = 100;
|
|
|
|
+ }
|
|
|
|
+ log( crop + " Growth Modifier: " + modifier + "%" );
|
|
|
|
+
|
|
|
|
+ return modifier;
|
|
|
|
+ }
|
|
|
|
+ private void growthModifiers()
|
|
|
|
+ {
|
|
|
|
+ cactusModifier = getAndValidateGrowth( "Cactus" );
|
|
|
|
+ caneModifier = getAndValidateGrowth( "Cane" );
|
|
|
|
+ melonModifier = getAndValidateGrowth( "Melon" );
|
|
|
|
+ mushroomModifier = getAndValidateGrowth( "Mushroom" );
|
|
|
|
+ pumpkinModifier = getAndValidateGrowth( "Pumpkin" );
|
|
|
|
+ saplingModifier = getAndValidateGrowth( "Sapling" );
|
|
|
|
+ wheatModifier = getAndValidateGrowth( "Wheat" );
|
2015-05-26 07:35:03 +00:00
|
|
|
+ wartModifier = getAndValidateGrowth( "NetherWart" );
|
2014-07-21 20:46:54 +00:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2016-02-29 21:33:06 +00:00
|
|
|
2.5.0
|
2014-07-21 20:46:54 +00:00
|
|
|
|