Commits
md_5 authored 5391d732ffc
1 - | From 4d50644cd2da7c1e386fedca41f08dd4dfae9ad1 Mon Sep 17 00:00:00 2001 |
1 + | From 4a3c68262a083af251a6a18b678889452fcf91dc Mon Sep 17 00:00:00 2001 |
2 2 | From: md_5 <git@md-5.net> |
3 3 | Date: Mon, 7 Mar 2016 22:14:13 +1100 |
4 4 | Subject: [PATCH] Crop Growth Rates |
5 5 | |
6 6 | Allows configuring the growth rates of crops as a percentage of their normal growth rate. |
7 7 | |
8 8 | diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java |
9 9 | index 0f5e4d5..8eebac1 100644 |
10 10 | --- a/src/main/java/net/minecraft/server/Block.java |
11 11 | +++ b/src/main/java/net/minecraft/server/Block.java |
111 111 | |
112 112 | if (world.getLightLevel(blockposition.up()) >= 9) { |
113 113 | float f = BlockCrops.a((Block) this, world, blockposition); |
114 114 | |
115 115 | - if (random.nextInt((int) (25.0F / f) + 1) == 0) { |
116 116 | + if (random.nextInt((int) ((100.0F / (this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier)) * (25.0F / f)) + 1) == 0) { // Spigot |
117 117 | int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue(); |
118 118 | |
119 119 | if (i < 7) { |
120 120 | diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java |
121 - | index 961ddb4..8860a96 100644 |
121 + | index 961ddb4..8b10672 100644 |
122 122 | --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java |
123 123 | +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java |
124 124 | |
125 125 | config.addDefault( "world-settings.default." + path, def ); |
126 126 | return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) ); |
127 127 | } |
128 128 | + |
129 129 | + // Crop growth rates |
130 130 | + public int cactusModifier; |
131 131 | + public int caneModifier; |
132 132 | + public int melonModifier; |
133 133 | + public int mushroomModifier; |
134 134 | + public int pumpkinModifier; |
135 135 | + public int saplingModifier; |
136 136 | + public int wheatModifier; |
137 137 | + public int wartModifier; |
138 138 | + private int getAndValidateGrowth(String crop) |
139 139 | + { |
140 - | + int modifier = getInt( "growth." + crop.toLowerCase() + "-modifier", 100 ); |
140 + | + int modifier = getInt( "growth." + crop.toLowerCase(java.util.Locale.ENGLISH) + "-modifier", 100 ); |
141 141 | + if ( modifier == 0 ) |
142 142 | + { |
143 143 | + log( "Cannot set " + crop + " growth to zero, defaulting to 100" ); |
144 144 | + modifier = 100; |
145 145 | + } |
146 146 | + log( crop + " Growth Modifier: " + modifier + "%" ); |
147 147 | + |
148 148 | + return modifier; |
149 149 | + } |
150 150 | + private void growthModifiers() |