Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 116 lines 3.9 kB view raw
1package net.minecraft.server; 2 3import org.bukkit.BlockChangeDelegate; 4 5import java.util.Random; 6 7public class WorldGenTaiga2 extends WorldGenerator { 8 9 public WorldGenTaiga2() { 10 } 11 12 public boolean a(World world, Random random, int i, int j, int k) { 13 // CraftBukkit start 14 // sk: The idea is to have (our) WorldServer implement 15 // BlockChangeDelegate and then we can implicitly cast World to 16 // WorldServer (a safe cast, AFAIK) and no code will be broken. This 17 // then allows plugins to catch manually-invoked generation events 18 return this.generate((BlockChangeDelegate) world, random, i, j, k); 19 } 20 21 public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) { 22 // CraftBukkit end 23 int l = random.nextInt(4) + 6; 24 int i1 = 1 + random.nextInt(2); 25 int j1 = l - i1; 26 int k1 = 2 + random.nextInt(2); 27 boolean flag = true; 28 29 if (j >= 1 && j + l + 1 <= 128) { 30 int l1; 31 int i2; 32 int j2; 33 int k2; 34 35 for (l1 = j; l1 <= j + 1 + l && flag; ++l1) { 36 boolean flag1 = true; 37 38 if (l1 - j < i1) { 39 k2 = 0; 40 } else { 41 k2 = k1; 42 } 43 44 for (i2 = i - k2; i2 <= i + k2 && flag; ++i2) { 45 for (int l2 = k - k2; l2 <= k + k2 && flag; ++l2) { 46 if (l1 >= 0 && l1 < 128) { 47 j2 = world.getTypeId(i2, l1, l2); 48 if (j2 != 0 && j2 != Block.LEAVES.id) { 49 flag = false; 50 } 51 } else { 52 flag = false; 53 } 54 } 55 } 56 } 57 58 if (!flag) { 59 return false; 60 } else { 61 l1 = world.getTypeId(i, j - 1, k); 62 if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) { 63 world.setRawTypeId(i, j - 1, k, Block.DIRT.id); 64 k2 = random.nextInt(2); 65 i2 = 1; 66 byte b0 = 0; 67 68 int i3; 69 int j3; 70 71 for (j2 = 0; j2 <= j1; ++j2) { 72 j3 = j + l - j2; 73 74 for (i3 = i - k2; i3 <= i + k2; ++i3) { 75 int k3 = i3 - i; 76 77 for (int l3 = k - k2; l3 <= k + k2; ++l3) { 78 int i4 = l3 - k; 79 80 if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.o[world.getTypeId(i3, j3, l3)] && !Block.leafDecayBlacklist.contains(world.getTypeId(l1, i2, k2))) { 81 world.setRawTypeIdAndData(i3, j3, l3, Block.LEAVES.id, 1); 82 } 83 } 84 } 85 86 if (k2 >= i2) { 87 k2 = b0; 88 b0 = 1; 89 ++i2; 90 if (i2 > k1) { 91 i2 = k1; 92 } 93 } else { 94 ++k2; 95 } 96 } 97 98 j2 = random.nextInt(3); 99 100 for (j3 = 0; j3 < l - j2; ++j3) { 101 i3 = world.getTypeId(i, j + j3, k); 102 if (i3 == 0 || i3 == Block.LEAVES.id) { 103 world.setRawTypeIdAndData(i, j + j3, k, Block.LOG.id, 1); 104 } 105 } 106 107 return true; 108 } else { 109 return false; 110 } 111 } 112 } else { 113 return false; 114 } 115 } 116}