diff options
author | mbax <matt@phozop.net> | 2013-11-04 07:07:38 -0600 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2013-11-30 19:26:12 -0600 |
commit | 2726696652179a5ead7dc07dd39edf7dfda687f7 (patch) | |
tree | ff78e22fdd4fc01889a5f6cc482b599f965cd93a /src/main/java/net/minecraft/server/WorldGenTrees.java | |
parent | ff8b70fbb7a96b9d2ff078afcf3b3ff90f200981 (diff) | |
download | craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar.gz craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar.lz craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar.xz craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.zip |
Update CraftBukkit to Minecraft 1.7.2
Diffstat (limited to 'src/main/java/net/minecraft/server/WorldGenTrees.java')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldGenTrees.java | 131 |
1 files changed, 66 insertions, 65 deletions
diff --git a/src/main/java/net/minecraft/server/WorldGenTrees.java b/src/main/java/net/minecraft/server/WorldGenTrees.java index 9354c865..065a3b25 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -2,9 +2,9 @@ package net.minecraft.server; import java.util.Random; -import org.bukkit.BlockChangeDelegate; // CraftBukkit +import org.bukkit.craftbukkit.CraftBlockChangeDelegate; // CraftBukkit -public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface +public class WorldGenTrees extends WorldGenTreeAbstract implements BlockSapling.TreeGenerator { // CraftBukkit - add interface private final int a; private final boolean b; @@ -25,35 +25,34 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe public boolean a(World world, Random random, int i, int j, int k) { // CraftBukkit start - Moved to generate - return this.generate((BlockChangeDelegate) world, random, i, j, k); + return this.generate(new CraftBlockChangeDelegate((org.bukkit.BlockChangeDelegate) world), random, i, j, k); } - public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) { + public boolean generate(CraftBlockChangeDelegate world, Random random, int i, int j, int k) { // CraftBukkit end int l = random.nextInt(3) + this.a; boolean flag = true; if (j >= 1 && j + l + 1 <= 256) { - int i1; byte b0; - int j1; - int k1; + int i1; + Block block; - for (i1 = j; i1 <= j + 1 + l; ++i1) { + for (int j1 = j; j1 <= j + 1 + l; ++j1) { b0 = 1; - if (i1 == j) { + if (j1 == j) { b0 = 0; } - if (i1 >= j + 1 + l - 2) { + if (j1 >= j + 1 + l - 2) { b0 = 2; } - for (int l1 = i - b0; l1 <= i + b0 && flag; ++l1) { - for (j1 = k - b0; j1 <= k + b0 && flag; ++j1) { - if (i1 >= 0 && i1 < 256) { - k1 = world.getTypeId(l1, i1, j1); - if (k1 != 0 && k1 != Block.LEAVES.id && k1 != Block.GRASS.id && k1 != Block.DIRT.id && k1 != Block.LOG.id) { + for (int k1 = i - b0; k1 <= i + b0 && flag; ++k1) { + for (i1 = k - b0; i1 <= k + b0 && flag; ++i1) { + if (j1 >= 0 && j1 < 256) { + block = world.getType(k1, j1, i1); + if (!this.a(block)) { flag = false; } } else { @@ -66,83 +65,85 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe if (!flag) { return false; } else { - i1 = world.getTypeId(i, j - 1, k); - if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 256 - l - 1) { - this.setType(world, i, j - 1, k, Block.DIRT.id); + Block block1 = world.getType(i, j - 1, k); + + if ((block1 == Blocks.GRASS || block1 == Blocks.DIRT || block1 == Blocks.SOIL) && j < 256 - l - 1) { + this.setType(world, i, j - 1, k, Blocks.DIRT); b0 = 3; byte b1 = 0; + int l1; int i2; int j2; int k2; - for (j1 = j - b0 + l; j1 <= j + l; ++j1) { - k1 = j1 - (j + l); - i2 = b1 + 1 - k1 / 2; + for (i1 = j - b0 + l; i1 <= j + l; ++i1) { + k2 = i1 - (j + l); + l1 = b1 + 1 - k2 / 2; - for (j2 = i - i2; j2 <= i + i2; ++j2) { - k2 = j2 - i; + for (i2 = i - l1; i2 <= i + l1; ++i2) { + j2 = i2 - i; - for (int l2 = k - i2; l2 <= k + i2; ++l2) { + for (int l2 = k - l1; l2 <= k + l1; ++l2) { int i3 = l2 - k; - if (Math.abs(k2) != i2 || Math.abs(i3) != i2 || random.nextInt(2) != 0 && k1 != 0) { - int j3 = world.getTypeId(j2, j1, l2); + if (Math.abs(j2) != l1 || Math.abs(i3) != l1 || random.nextInt(2) != 0 && k2 != 0) { + Block block2 = world.getType(i2, i1, l2); - if (j3 == 0 || j3 == Block.LEAVES.id) { - this.setTypeAndData(world, j2, j1, l2, Block.LEAVES.id, this.d); + if (block2.getMaterial() == Material.AIR || block2.getMaterial() == Material.LEAVES) { + this.setTypeAndData(world, i2, i1, l2, Blocks.LEAVES, this.d); } } } } } - for (j1 = 0; j1 < l; ++j1) { - k1 = world.getTypeId(i, j + j1, k); - if (k1 == 0 || k1 == Block.LEAVES.id) { - this.setTypeAndData(world, i, j + j1, k, Block.LOG.id, this.c); - if (this.b && j1 > 0) { - if (random.nextInt(3) > 0 && world.isEmpty(i - 1, j + j1, k)) { - this.setTypeAndData(world, i - 1, j + j1, k, Block.VINE.id, 8); + for (i1 = 0; i1 < l; ++i1) { + block = world.getType(i, j + i1, k); + if (block.getMaterial() == Material.AIR || block.getMaterial() == Material.LEAVES) { + this.setTypeAndData(world, i, j + i1, k, Blocks.LOG, this.c); + if (this.b && i1 > 0) { + if (random.nextInt(3) > 0 && world.isEmpty(i - 1, j + i1, k)) { + this.setTypeAndData(world, i - 1, j + i1, k, Blocks.VINE, 8); } - if (random.nextInt(3) > 0 && world.isEmpty(i + 1, j + j1, k)) { - this.setTypeAndData(world, i + 1, j + j1, k, Block.VINE.id, 2); + if (random.nextInt(3) > 0 && world.isEmpty(i + 1, j + i1, k)) { + this.setTypeAndData(world, i + 1, j + i1, k, Blocks.VINE, 2); } - if (random.nextInt(3) > 0 && world.isEmpty(i, j + j1, k - 1)) { - this.setTypeAndData(world, i, j + j1, k - 1, Block.VINE.id, 1); + if (random.nextInt(3) > 0 && world.isEmpty(i, j + i1, k - 1)) { + this.setTypeAndData(world, i, j + i1, k - 1, Blocks.VINE, 1); } - if (random.nextInt(3) > 0 && world.isEmpty(i, j + j1, k + 1)) { - this.setTypeAndData(world, i, j + j1, k + 1, Block.VINE.id, 4); + if (random.nextInt(3) > 0 && world.isEmpty(i, j + i1, k + 1)) { + this.setTypeAndData(world, i, j + i1, k + 1, Blocks.VINE, 4); } } } } if (this.b) { - for (j1 = j - 3 + l; j1 <= j + l; ++j1) { - k1 = j1 - (j + l); - i2 = 2 - k1 / 2; - - for (j2 = i - i2; j2 <= i + i2; ++j2) { - for (k2 = k - i2; k2 <= k + i2; ++k2) { - if (world.getTypeId(j2, j1, k2) == Block.LEAVES.id) { - if (random.nextInt(4) == 0 && world.getTypeId(j2 - 1, j1, k2) == 0) { - this.b(world, j2 - 1, j1, k2, 8); + for (i1 = j - 3 + l; i1 <= j + l; ++i1) { + k2 = i1 - (j + l); + l1 = 2 - k2 / 2; + + for (i2 = i - l1; i2 <= i + l1; ++i2) { + for (j2 = k - l1; j2 <= k + l1; ++j2) { + if (world.getType(i2, i1, j2).getMaterial() == Material.LEAVES) { + if (random.nextInt(4) == 0 && world.getType(i2 - 1, i1, j2).getMaterial() == Material.AIR) { + this.a(world, i2 - 1, i1, j2, 8); } - if (random.nextInt(4) == 0 && world.getTypeId(j2 + 1, j1, k2) == 0) { - this.b(world, j2 + 1, j1, k2, 2); + if (random.nextInt(4) == 0 && world.getType(i2 + 1, i1, j2).getMaterial() == Material.AIR) { + this.a(world, i2 + 1, i1, j2, 2); } - if (random.nextInt(4) == 0 && world.getTypeId(j2, j1, k2 - 1) == 0) { - this.b(world, j2, j1, k2 - 1, 1); + if (random.nextInt(4) == 0 && world.getType(i2, i1, j2 - 1).getMaterial() == Material.AIR) { + this.a(world, i2, i1, j2 - 1, 1); } - if (random.nextInt(4) == 0 && world.getTypeId(j2, j1, k2 + 1) == 0) { - this.b(world, j2, j1, k2 + 1, 4); + if (random.nextInt(4) == 0 && world.getType(i2, i1, j2 + 1).getMaterial() == Material.AIR) { + this.a(world, i2, i1, j2 + 1, 4); } } } @@ -150,11 +151,11 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe } if (random.nextInt(5) == 0 && l > 5) { - for (j1 = 0; j1 < 2; ++j1) { - for (k1 = 0; k1 < 4; ++k1) { - if (random.nextInt(4 - j1) == 0) { - i2 = random.nextInt(3); - this.setTypeAndData(world, i + Direction.a[Direction.f[k1]], j + l - 5 + j1, k + Direction.b[Direction.f[k1]], Block.COCOA.id, i2 << 2 | k1); + for (i1 = 0; i1 < 2; ++i1) { + for (k2 = 0; k2 < 4; ++k2) { + if (random.nextInt(4 - i1) == 0) { + l1 = random.nextInt(3); + this.setTypeAndData(world, i + Direction.a[Direction.f[k2]], j + l - 5 + i1, k + Direction.b[Direction.f[k2]], Blocks.COCOA, l1 << 2 | k2); } } } @@ -172,17 +173,17 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe } // CraftBukkit - Changed world to BlockChangeDelegate - private void b(BlockChangeDelegate world, int i, int j, int k, int l) { - this.setTypeAndData(world, i, j, k, Block.VINE.id, l); + private void a(CraftBlockChangeDelegate world, int i, int j, int k, int l) { + this.setTypeAndData(world, i, j, k, Blocks.VINE, l); int i1 = 4; while (true) { --j; - if (world.getTypeId(i, j, k) != 0 || i1 <= 0) { + if (world.getType(i, j, k).getMaterial() != Material.AIR || i1 <= 0) { return; } - this.setTypeAndData(world, i, j, k, Block.VINE.id, l); + this.setTypeAndData(world, i, j, k, Blocks.VINE, l); --i1; } } |