2014-11-30 23:16:48 +01:00
|
|
|
From 46825f35d92e4d5d2075470c0c17005e35ca6b13 Mon Sep 17 00:00:00 2001
|
2014-07-21 22:46:54 +02: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
|
2014-11-28 02:17:45 +01:00
|
|
|
index 59d03ce..12e2b79 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -927,4 +927,16 @@ public class Block {
|
2014-07-21 22:46:54 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java
|
2014-11-28 02:17:45 +01:00
|
|
|
index 7046683..8569204 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockCactus.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockCactus.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -29,7 +29,7 @@ public class BlockCactus extends Block {
|
|
|
|
if (i < 3) {
|
|
|
|
int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue();
|
|
|
|
|
|
|
|
- if (j == 15) {
|
|
|
|
+ if (j >= (byte) range(3, (world.growthOdds / world.spigotConfig.cactusModifier * 15) + 0.5F, 15)) { // Spigot
|
|
|
|
world.setTypeUpdate(blockposition1, this.getBlockData());
|
|
|
|
IBlockData iblockdata1 = iblockdata.set(BlockCactus.AGE, Integer.valueOf(0));
|
2014-07-21 22:46:54 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java
|
2014-11-28 02:17:45 +01:00
|
|
|
index 2ce2e34..d61251f 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockCrops.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockCrops.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -32,8 +32,7 @@ public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement
|
|
|
|
if (i < 7) {
|
|
|
|
float f = a((Block) this, world, blockposition);
|
2014-07-21 22:46:54 +02:00
|
|
|
|
|
|
|
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
2014-11-28 02:17:45 +01:00
|
|
|
- // CraftBukkit start
|
|
|
|
+ if (random.nextInt((int) (world.growthOdds / world.spigotConfig.wheatModifier * (25.0F / f)) + 1) == 0) { // Spigot // CraftBukkit start
|
|
|
|
IBlockData data = iblockdata.set(AGE, Integer.valueOf(i + 1));
|
|
|
|
CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
|
|
|
|
// CraftBukkit end
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java
|
2014-11-29 01:06:26 +01:00
|
|
|
index fc0e540..09cdd8a 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockGrass.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockGrass.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -45,7 +45,7 @@ public class BlockGrass extends Block implements IBlockFragilePlantElement {
|
2014-07-21 22:46:54 +02:00
|
|
|
// CraftBukkit end
|
2014-11-28 02:17:45 +01:00
|
|
|
} else {
|
|
|
|
if (world.getLightLevel(blockposition.up()) >= 9) {
|
|
|
|
- for (int i = 0; i < 4; ++i) {
|
|
|
|
+ for (int i = 0; i < Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); ++i) { // Spigot
|
|
|
|
BlockPosition blockposition1 = blockposition.a(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
|
|
|
Block block = world.getType(blockposition1.up()).getBlock();
|
|
|
|
IBlockData iblockdata1 = world.getType(blockposition1);
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java
|
2014-11-28 02:17:45 +01:00
|
|
|
index f2944be..decefa9 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockMushroom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockMushroom.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -20,7 +20,7 @@ public class BlockMushroom extends BlockPlant implements IBlockFragilePlantEleme
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2014-11-28 02:17:45 +01: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 22:46:54 +02:00
|
|
|
- if (random.nextInt(25) == 0) {
|
2014-11-28 02:17:45 +01:00
|
|
|
+ if (random.nextInt(Math.max(1, (int) world.growthOdds / world.spigotConfig.mushroomModifier * 25)) == 0) { // Spigot int i = 5;
|
|
|
|
int i = 5;
|
|
|
|
boolean flag = true;
|
|
|
|
Iterator iterator = BlockPosition.b(blockposition.a(-4, -1, -4), blockposition.a(4, 1, 4)).iterator();
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockMycel.java b/src/main/java/net/minecraft/server/BlockMycel.java
|
2014-11-28 02:17:45 +01:00
|
|
|
index 8f792e4..cb383a5 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockMycel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockMycel.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -44,7 +44,7 @@ public class BlockMycel extends Block {
|
2014-07-21 22:46:54 +02:00
|
|
|
// CraftBukkit end
|
2014-11-28 02:17:45 +01:00
|
|
|
} else {
|
|
|
|
if (world.getLightLevel(blockposition.up()) >= 9) {
|
|
|
|
- for (int i = 0; i < 4; ++i) {
|
|
|
|
+ for (int i = 0; i < Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); ++i) { // Spigot
|
|
|
|
BlockPosition blockposition1 = blockposition.a(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
|
|
|
IBlockData iblockdata1 = world.getType(blockposition1);
|
|
|
|
Block block = world.getType(blockposition1.up()).getBlock();
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java
|
2014-11-28 02:17:45 +01:00
|
|
|
index ae7c617..11631da 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockReed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockReed.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -28,7 +28,7 @@ public class BlockReed extends Block {
|
|
|
|
if (i < 3) {
|
|
|
|
int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
- if (j == 15) {
|
|
|
|
+ if (j >= (byte) range(3, (world.growthOdds / world.spigotConfig.caneModifier * 15) + 0.5F, 15)) { // Spigot
|
|
|
|
// CraftBukkit start
|
|
|
|
// world.setTypeUpdate(blockposition.up(), this.getBlockData());
|
|
|
|
// world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4);
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java
|
2014-11-28 02:17:45 +01:00
|
|
|
index ff4f576..39c0cba 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockSapling.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockSapling.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -28,7 +28,7 @@ public class BlockSapling extends BlockPlant implements IBlockFragilePlantElemen
|
|
|
|
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
2014-07-21 22:46:54 +02:00
|
|
|
if (!world.isStatic) {
|
2014-11-28 02:17:45 +01:00
|
|
|
super.b(world, blockposition, iblockdata, random);
|
|
|
|
- if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
|
|
|
|
+ if (world.getLightLevel(blockposition.up()) >= 9 && (random.nextInt(Math.max(2, (int) ((world.growthOdds / world.spigotConfig.saplingModifier * 7) + 0.5F))) == 0)) { // Spigot) {
|
2014-07-21 22:46:54 +02: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
|
2014-11-29 01:06:26 +01:00
|
|
|
index e4c65ff..dba443a 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockStem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockStem.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -47,7 +47,7 @@ public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
|
|
|
|
if (world.getLightLevel(blockposition.up()) >= 9) {
|
|
|
|
float f = BlockCrops.a((Block) this, world, blockposition);
|
2014-07-21 22:46:54 +02:00
|
|
|
|
|
|
|
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
|
|
|
+ if (random.nextInt((int) (world.growthOdds / (this == Blocks.PUMPKIN_STEM? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) * (25.0F / f)) + 1) == 0) { // Spigot
|
2014-11-28 02:17:45 +01:00
|
|
|
int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue();
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
if (i < 7) {
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
index 90a227f..7e79ba5 100644
|
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
@@ -79,4 +79,35 @@ public class SpigotWorldConfig
|
|
|
|
clearChunksOnTick = getBoolean( "clear-tick-list", false );
|
|
|
|
log( "Clear tick list: " + clearChunksOnTick );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Crop growth rates
|
|
|
|
+ public int cactusModifier;
|
|
|
|
+ public int caneModifier;
|
|
|
|
+ public int melonModifier;
|
|
|
|
+ public int mushroomModifier;
|
|
|
|
+ public int pumpkinModifier;
|
|
|
|
+ public int saplingModifier;
|
|
|
|
+ public int wheatModifier;
|
|
|
|
+ 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" );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2014-11-28 02:17:45 +01:00
|
|
|
2.1.0
|
2014-07-21 22:46:54 +02:00
|
|
|
|