Prevent crash from division by 0 in growth rates

This commit is contained in:
Dmck2b 2013-12-03 08:14:39 +11:00 committed by md_5
parent 2e5d2f1fca
commit 910aa42a6a

View File

@ -1,9 +1,88 @@
From 31c2cbada240f1ffe7e4d5bee414fba7da33def0 Mon Sep 17 00:00:00 2001
From bade146cff75a2d2fca7a80c11ce655816a7517c Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 17:17:20 +1000
Subject: [PATCH] Crop Growth Rates
diff --git a/CraftBukkit-Patches/0071-Growth-Rates-Divide-By-0-Prevention.patch b/CraftBukkit-Patches/0071-Growth-Rates-Divide-By-0-Prevention.patch
new file mode 100644
index 0000000..e7912f7
--- /dev/null
+++ b/CraftBukkit-Patches/0071-Growth-Rates-Divide-By-0-Prevention.patch
@@ -0,0 +1,73 @@
+From 5cf798e92bfc9c03460dffe32887940d27eaaf11 Mon Sep 17 00:00:00 2001
+From: Dmck2b <dmck2b+github@gmail.com>
+Date: Mon, 2 Dec 2013 18:52:59 +0000
+Subject: [PATCH] Growth Rates Divide By 0 Prevention
+
+
+diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
+index 300db67..95e3716 100644
+--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
++++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
+@@ -88,24 +88,59 @@ public class SpigotWorldConfig
+ private void growthModifiers()
+ {
+ cactusModifier = getInt( "growth.cactus-modifier", 100 );
++ if ( cactusModifier == 0 ) {
++ log( "***WARNING*** You have set your Cactus Growth Modifier for " + worldName + "to 0. Defaulting back to 100 to prevent a division by 0 crash." );
++ log( "***WARNING*** Please fix your Spigot.yml configuration to hide this message." );
++ cactusModifier = 100;
++ }
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ caneModifier = getInt( "growth.cane-modifier", 100 );
++ if ( caneModifier == 0 ) {
++ log( "***WARNING*** You have set your Sugar Cane Growth Modifier for " + worldName + "to 0. Defaulting back to 100 to prevent a division by 0 crash." );
++ log( "***WARNING*** Please fix your Spigot.yml configuration to hide this message." );
++ caneModifier = 100;
++ }
+ log( "Cane Growth Modifier: " + caneModifier + "%" );
+
+ melonModifier = getInt( "growth.melon-modifier", 100 );
++ if ( melonModifier == 0 ) {
++ log( "***WARNING*** You have set your Melon Growth Modifier for " + worldName + "to 0. Defaulting back to 100 to prevent a division by 0 crash." );
++ log( "***WARNING*** Please fix your Spigot.yml configuration to hide this message." );
++ melonModifier = 100;
++ }
+ log( "Melon Growth Modifier: " + melonModifier + "%" );
+
+ mushroomModifier = getInt( "growth.mushroom-modifier", 100 );
++ if ( mushroomModifier == 0 ) {
++ log( "***WARNING*** You have set your Mushroom Growth Modifier for " + worldName + "to 0. Defaulting back to 100 to prevent a division by 0 crash." );
++ log( "***WARNING*** Please fix your Spigot.yml configuration to hide this message." );
++ mushroomModifier = 100;
++ }
+ log( "Mushroom Growth Modifier: " + mushroomModifier + "%" );
+
+ pumpkinModifier = getInt( "growth.pumpkin-modifier", 100 );
++ if ( pumpkinModifier == 0 ) {
++ log( "***WARNING*** You have set your Pumpkin Growth Modifier for " + worldName + "to 0. Defaulting back to 100 to prevent a division by 0 crash." );
++ log( "***WARNING*** Please fix your Spigot.yml configuration to hide this message." );
++ pumpkinModifier = 100;
++ }
+ log( "Pumpkin Growth Modifier: " + pumpkinModifier + "%" );
+
+ saplingModifier = getInt( "growth.sapling-modifier", 100 );
++ if ( saplingModifier == 0 ) {
++ log( "***WARNING*** You have set your Sapling Growth Modifier for " + worldName + "to 0. Defaulting back to 100 to prevent a division by 0 crash." );
++ log( "***WARNING*** Please fix your Spigot.yml configuration to hide this message." );
++ saplingModifier = 100;
++ }
+ log( "Sapling Growth Modifier: " + saplingModifier + "%" );
+
+ wheatModifier = getInt( "growth.wheat-modifier", 100 );
++ if ( wheatModifier == 0 ) {
++ log( "***WARNING*** You have set your Wheat Growth Modifier for " + worldName + "to 0. Defaulting back to 100 to prevent a division by 0 crash." );
++ log( "***WARNING*** Please fix your Spigot.yml configuration to hide this message." );
++ wheatModifier = 100;
++ }
+ log( "Wheat Growth Modifier: " + wheatModifier + "%" );
+ }
+
+--
+1.8.5
+
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
index dca832f..ad4e3a2 100644
--- a/src/main/java/net/minecraft/server/Block.java