geforkt von Mirrors/Paper
[Bleeding] Completely fix the tree generation algorithm to make it near identical to vanilla as well as fix potential bugs associated with disappearing saplings.
Dieser Commit ist enthalten in:
Ursprung
ea60181a87
Commit
7966531113
@ -2,6 +2,7 @@ package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
// CraftBukkit start
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
@ -43,56 +44,61 @@ public class BlockSapling extends BlockFlower {
|
||||
// CraftBukkit - added bonemeal, player and itemstack
|
||||
public void grow(World world, int i, int j, int k, Random random, boolean bonemeal, Player player, ItemStack itemstack) {
|
||||
int l = world.getData(i, j, k) & 3;
|
||||
|
||||
// CraftBukkit start - records tree generation and calls StructureGrowEvent
|
||||
StructureGrowDelegate delegate = new StructureGrowDelegate(world);
|
||||
TreeType treeType;
|
||||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
// CraftBukkit start - records tree generation and calls StructureGrowEvent
|
||||
StructureGrowDelegate delegate = new StructureGrowDelegate(world);
|
||||
TreeType treeType = null;
|
||||
TreeGenerator gen = null;
|
||||
boolean grownTree = false;
|
||||
boolean megaTree = false;
|
||||
// All of these are 'false' because we need the 'raw' calls so the block-delegate works
|
||||
boolean flag = false;
|
||||
|
||||
if (l == 1) {
|
||||
treeType = TreeType.REDWOOD;
|
||||
world.setRawTypeId(i, j, k, 0);
|
||||
grownTree = new WorldGenTaiga2(false).generate(delegate, random, i, j, k);
|
||||
gen = new WorldGenTaiga2(false);
|
||||
} else if (l == 2) {
|
||||
treeType = TreeType.BIRCH;
|
||||
world.setRawTypeId(i, j, k, 0);
|
||||
grownTree = new WorldGenForest(false).generate(delegate, random, i, j, k);
|
||||
gen = new WorldGenForest(false);
|
||||
} else if (l == 3) {
|
||||
treeType = TreeType.JUNGLE;
|
||||
for (i1 = 0; i1 >= -1; --i1) {
|
||||
for (j1 = 0; j1 >= -1; --j1) {
|
||||
if (world.getTypeId(i + i1, j, k + j1) == this.id && world.getTypeId(i + i1 + 1, j, k + j1) == this.id && world.getTypeId(i + i1, j, k + j1 + 1) == this.id && world.getTypeId(i + i1 + 1, j, k + j1 + 1) == this.id) {
|
||||
world.setRawTypeId(i + i1, j, k + j1, 0);
|
||||
world.setRawTypeId(i + i1 + 1, j, k + j1, 0);
|
||||
world.setRawTypeId(i + i1, j, k + j1 + 1, 0);
|
||||
world.setRawTypeId(i + i1 + 1, j, k + j1 + 1, 0);
|
||||
grownTree = new WorldGenMegaTree(false, 10 + random.nextInt(20), 3, 3).generate(delegate, random, i + i1, j, k + j1);
|
||||
megaTree = true;
|
||||
treeType = TreeType.JUNGLE;
|
||||
gen = new WorldGenMegaTree(false, 10 + random.nextInt(20), 3, 3);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gen != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!grownTree) {
|
||||
|
||||
if (gen == null) {
|
||||
j1 = 0;
|
||||
i1 = 0;
|
||||
world.setRawTypeId(i, j, k, 0);
|
||||
grownTree = new WorldGenTrees(false, 4 + random.nextInt(7), 3, 3, false).generate(delegate, random, i, j, k);
|
||||
treeType = TreeType.TREE;
|
||||
gen = new WorldGenTrees(false, 4 + random.nextInt(7), 3, 3, false);
|
||||
}
|
||||
} else {
|
||||
treeType = TreeType.TREE;
|
||||
gen = new WorldGenTrees(false);
|
||||
if (random.nextInt(10) == 0) {
|
||||
treeType = TreeType.BIG_TREE;
|
||||
world.setRawTypeId(i, j, k, 0);
|
||||
grownTree = new WorldGenBigTree(false).generate(delegate, random, i, j, k);
|
||||
} else {
|
||||
treeType = TreeType.TREE;
|
||||
world.setRawTypeId(i, j, k, 0);
|
||||
grownTree = new WorldGenTrees(false).generate(delegate, random, i, j, k);
|
||||
gen = new WorldGenBigTree(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
world.setRawTypeId(i + i1, j, k + j1, 0);
|
||||
world.setRawTypeId(i + i1 + 1, j, k + j1, 0);
|
||||
world.setRawTypeId(i + i1, j, k + j1 + 1, 0);
|
||||
world.setRawTypeId(i + i1 + 1, j, k + j1 + 1, 0);
|
||||
} else {
|
||||
world.setRawTypeId(i, j, k, 0);
|
||||
}
|
||||
grownTree = gen.generate(delegate, random, i + i1, j, k + j1);
|
||||
if (grownTree) {
|
||||
Location location = new Location(world.getWorld(), i, j, k);
|
||||
StructureGrowEvent event = new StructureGrowEvent(location, treeType, bonemeal, player, delegate.getBlocks());
|
||||
@ -108,10 +114,8 @@ public class BlockSapling extends BlockFlower {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!grownTree) {
|
||||
if (megaTree) {
|
||||
// CraftBukkit end
|
||||
if (flag) {
|
||||
world.setRawTypeIdAndData(i + i1, j, k + j1, this.id, l);
|
||||
world.setRawTypeIdAndData(i + i1 + 1, j, k + j1, this.id, l);
|
||||
world.setRawTypeIdAndData(i + i1, j, k + j1 + 1, this.id, l);
|
||||
@ -120,9 +124,19 @@ public class BlockSapling extends BlockFlower {
|
||||
world.setRawTypeIdAndData(i, j, k, this.id, l);
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
protected int getDropData(int i) {
|
||||
return i & 3;
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
interface TreeGenerator {
|
||||
|
||||
public boolean a(World world, Random random, int i, int j, int k);
|
||||
|
||||
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k);
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
||||
|
||||
public class WorldGenBigTree extends WorldGenerator {
|
||||
public class WorldGenBigTree extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface
|
||||
|
||||
static final byte[] a = new byte[] { (byte) 2, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 1};
|
||||
Random b = new Random();
|
||||
|
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
||||
|
||||
public class WorldGenForest extends WorldGenerator {
|
||||
public class WorldGenForest extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface
|
||||
|
||||
public WorldGenForest(boolean flag) {
|
||||
super(flag);
|
||||
|
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
||||
|
||||
public class WorldGenMegaTree extends WorldGenerator {
|
||||
public class WorldGenMegaTree extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface
|
||||
|
||||
private final int a;
|
||||
private final int b;
|
||||
|
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
||||
|
||||
public class WorldGenTaiga1 extends WorldGenerator {
|
||||
public class WorldGenTaiga1 extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface
|
||||
|
||||
public WorldGenTaiga1() {}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
||||
|
||||
public class WorldGenTaiga2 extends WorldGenerator {
|
||||
public class WorldGenTaiga2 extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface
|
||||
|
||||
public WorldGenTaiga2(boolean flag) {
|
||||
super(flag);
|
||||
|
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
||||
|
||||
public class WorldGenTrees extends WorldGenerator {
|
||||
public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface
|
||||
|
||||
private final int a;
|
||||
private final boolean b;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren