diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-23 02:37:56 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-23 02:37:56 +0000 |
commit | f759e0b60d3a575d31921c930e436af321b0e7e8 (patch) | |
tree | 4b1eb7ac01670854c686b1f6faa2f97ff337f7d7 /src/main/java/net/minecraft/server/WorldGenTrees.java | |
parent | a124bfdab59cc9a9d8369425027e61eccd1d62fb (diff) | |
download | craftbukkit-f759e0b60d3a575d31921c930e436af321b0e7e8.tar craftbukkit-f759e0b60d3a575d31921c930e436af321b0e7e8.tar.gz craftbukkit-f759e0b60d3a575d31921c930e436af321b0e7e8.tar.lz craftbukkit-f759e0b60d3a575d31921c930e436af321b0e7e8.tar.xz craftbukkit-f759e0b60d3a575d31921c930e436af321b0e7e8.zip |
Update to Minecraft 1.3 beta
Diffstat (limited to 'src/main/java/net/minecraft/server/WorldGenTrees.java')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldGenTrees.java | 200 |
1 files changed, 100 insertions, 100 deletions
diff --git a/src/main/java/net/minecraft/server/WorldGenTrees.java b/src/main/java/net/minecraft/server/WorldGenTrees.java index a6057e3b..22f6d416 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -1,100 +1,100 @@ -package net.minecraft.server;
-
-import java.util.Random;
-
-// CraftBukkit start
-import org.bukkit.BlockChangeDelegate;
-// CraftBukkit end
-
-public class WorldGenTrees extends WorldGenerator {
-
- public WorldGenTrees() {}
-
- public boolean a(World world, Random random, int i, int j, int k) {
- // CraftBukkit start
- // sk: The idea is to have (our) WorldServer implement
- // BlockChangeDelegate and then we can implicitly cast World to
- // WorldServer (a safe cast, AFAIK) and no code will be broken. This
- // then allows plugins to catch manually-invoked generation events
- return generate((BlockChangeDelegate)world, random, i, j, k);
- }
-
- public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
- // CraftBukkit end
- int l = random.nextInt(3) + 4;
- boolean flag = true;
-
- if (j >= 1 && j + l + 1 <= 128) {
- int i1;
- int j1;
- int k1;
- int l1;
-
- for (i1 = j; i1 <= j + 1 + l; ++i1) {
- byte b0 = 1;
-
- if (i1 == j) {
- b0 = 0;
- }
-
- if (i1 >= j + 1 + l - 2) {
- b0 = 2;
- }
-
- for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) {
- for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) {
- if (i1 >= 0 && i1 < 128) {
- l1 = world.getTypeId(j1, i1, k1);
- if (l1 != 0 && l1 != Block.LEAVES.id) {
- flag = false;
- }
- } else {
- flag = false;
- }
- }
- }
- }
-
- if (!flag) {
- return false;
- } else {
- i1 = world.getTypeId(i, j - 1, k);
- if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) {
- world.setTypeId(i, j - 1, k, Block.DIRT.id);
-
- int i2;
-
- for (i2 = j - 3 + l; i2 <= j + l; ++i2) {
- j1 = i2 - (j + l);
- k1 = 1 - j1 / 2;
-
- for (l1 = i - k1; l1 <= i + k1; ++l1) {
- int j2 = l1 - i;
-
- for (int k2 = k - k1; k2 <= k + k1; ++k2) {
- int l2 = k2 - k;
-
- if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) {
- world.setTypeId(l1, i2, k2, Block.LEAVES.id);
- }
- }
- }
- }
-
- for (i2 = 0; i2 < l; ++i2) {
- j1 = world.getTypeId(i, j + i2, k);
- if (j1 == 0 || j1 == Block.LEAVES.id) {
- world.setTypeId(i, j + i2, k, Block.LOG.id);
- }
- }
-
- return true;
- } else {
- return false;
- }
- }
- } else {
- return false;
- }
- }
-}
+package net.minecraft.server; + +import java.util.Random; + +// CraftBukkit start +import org.bukkit.BlockChangeDelegate; +// CraftBukkit end + +public class WorldGenTrees extends WorldGenerator { + + public WorldGenTrees() {} + + public boolean a(World world, Random random, int i, int j, int k) { + // CraftBukkit start + // sk: The idea is to have (our) WorldServer implement + // BlockChangeDelegate and then we can implicitly cast World to + // WorldServer (a safe cast, AFAIK) and no code will be broken. This + // then allows plugins to catch manually-invoked generation events + return generate((BlockChangeDelegate)world, random, i, j, k); + } + + public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) { + // CraftBukkit end + int l = random.nextInt(3) + 4; + boolean flag = true; + + if (j >= 1 && j + l + 1 <= 128) { + int i1; + int j1; + int k1; + int l1; + + for (i1 = j; i1 <= j + 1 + l; ++i1) { + byte b0 = 1; + + if (i1 == j) { + b0 = 0; + } + + if (i1 >= j + 1 + l - 2) { + b0 = 2; + } + + for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) { + for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) { + if (i1 >= 0 && i1 < 128) { + l1 = world.getTypeId(j1, i1, k1); + if (l1 != 0 && l1 != Block.LEAVES.id) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + i1 = world.getTypeId(i, j - 1, k); + if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) { + world.setTypeId(i, j - 1, k, Block.DIRT.id); + + int i2; + + for (i2 = j - 3 + l; i2 <= j + l; ++i2) { + j1 = i2 - (j + l); + k1 = 1 - j1 / 2; + + for (l1 = i - k1; l1 <= i + k1; ++l1) { + int j2 = l1 - i; + + for (int k2 = k - k1; k2 <= k + k1; ++k2) { + int l2 = k2 - k; + + if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) { + world.setTypeId(l1, i2, k2, Block.LEAVES.id); + } + } + } + } + + for (i2 = 0; i2 < l; ++i2) { + j1 = world.getTypeId(i, j + i2, k); + if (j1 == 0 || j1 == Block.LEAVES.id) { + world.setTypeId(i, j + i2, k, Block.LOG.id); + } + } + + return true; + } else { + return false; + } + } + } else { + return false; + } + } +} |