Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 103 lines 3.6 kB view raw
1package net.minecraft.server; 2 3import org.bukkit.BlockChangeDelegate; 4 5import java.util.Random; 6 7public class WorldGenTaiga1 extends WorldGenerator { 8 9 public WorldGenTaiga1() { 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(5) + 7; 24 int i1 = l - random.nextInt(2) - 3; 25 int j1 = l - i1; 26 int k1 = 1 + random.nextInt(j1 + 1); 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 int l2; 35 36 for (l1 = j; l1 <= j + 1 + l && flag; ++l1) { 37 boolean flag1 = true; 38 39 if (l1 - j < i1) { 40 l2 = 0; 41 } else { 42 l2 = k1; 43 } 44 45 for (i2 = i - l2; i2 <= i + l2 && flag; ++i2) { 46 for (j2 = k - l2; j2 <= k + l2 && flag; ++j2) { 47 if (l1 >= 0 && l1 < 128) { 48 k2 = world.getTypeId(i2, l1, j2); 49 if (k2 != 0 && k2 != Block.LEAVES.id) { 50 flag = false; 51 } 52 } else { 53 flag = false; 54 } 55 } 56 } 57 } 58 59 if (!flag) { 60 return false; 61 } else { 62 l1 = world.getTypeId(i, j - 1, k); 63 if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) { 64 world.setRawTypeId(i, j - 1, k, Block.DIRT.id); 65 l2 = 0; 66 67 for (i2 = j + l; i2 >= j + i1; --i2) { 68 for (j2 = i - l2; j2 <= i + l2; ++j2) { 69 k2 = j2 - i; 70 71 for (int i3 = k - l2; i3 <= k + l2; ++i3) { 72 int j3 = i3 - k; 73 74 if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.o[world.getTypeId(j2, i2, i3)] && !Block.leafDecayBlacklist.contains(world.getTypeId(l1, i2, k2))) { 75 world.setRawTypeIdAndData(j2, i2, i3, Block.LEAVES.id, 1); 76 } 77 } 78 } 79 80 if (l2 >= 1 && i2 == j + i1 + 1) { 81 --l2; 82 } else if (l2 < k1) { 83 ++l2; 84 } 85 } 86 87 for (i2 = 0; i2 < l - 1; ++i2) { 88 j2 = world.getTypeId(i, j + i2, k); 89 if (j2 == 0 || j2 == Block.LEAVES.id) { 90 world.setRawTypeIdAndData(i, j + i2, k, Block.LOG.id, 1); 91 } 92 } 93 94 return true; 95 } else { 96 return false; 97 } 98 } 99 } else { 100 return false; 101 } 102 } 103}