summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2012-01-15 05:58:56 +0000
committerNathan Adams <dinnerbone@dinnerbone.com>2012-01-15 05:58:56 +0000
commit23adb0d02f6b75a1f7463cc905e38b4145969681 (patch)
tree0f8a5075e5ebbc4e2a1a14f82adc68dade3d655a /src
parentb3698055902c3dddea53f3e03cea791b60ab0e20 (diff)
downloadcraftbukkit-23adb0d02f6b75a1f7463cc905e38b4145969681.tar
craftbukkit-23adb0d02f6b75a1f7463cc905e38b4145969681.tar.gz
craftbukkit-23adb0d02f6b75a1f7463cc905e38b4145969681.tar.lz
craftbukkit-23adb0d02f6b75a1f7463cc905e38b4145969681.tar.xz
craftbukkit-23adb0d02f6b75a1f7463cc905e38b4145969681.zip
Minor optimization in BlockGrass by only checking light once instead of twice. Thanks to oloflarsson for the PR.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/BlockGrass.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java
index 97afac5d..27762345 100644
--- a/src/main/java/net/minecraft/server/BlockGrass.java
+++ b/src/main/java/net/minecraft/server/BlockGrass.java
@@ -21,8 +21,9 @@ public class BlockGrass extends Block {
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
- if (world.getLightLevel(i, j + 1, k) < 4 && Block.q[world.getTypeId(i, j + 1, k)] > 2) {
- // CraftBukkit start
+ // CraftBukkit start - reuse getLightLevel
+ int lightLevel = world.getLightLevel(i, j + 1, k);
+ if (lightLevel < 4 && Block.q[world.getTypeId(i, j + 1, k)] > 2) {
org.bukkit.World bworld = world.getWorld();
org.bukkit.block.BlockState blockState = bworld.getBlockAt(i, j, k).getState();
blockState.setTypeId(Block.DIRT.id);
@@ -33,8 +34,8 @@ public class BlockGrass extends Block {
if (!event.isCancelled()) {
blockState.update(true);
}
- // CraftBukkit end
- } else if (world.getLightLevel(i, j + 1, k) >= 9) {
+ } else if (lightLevel >= 9) {
+ // CraftBukkit end
for (int l = 0; l < 4; ++l) {
int i1 = i + random.nextInt(3) - 1;
int j1 = j + random.nextInt(5) - 3;