diff options
Diffstat (limited to 'src/main/java/net/minecraft/server')
7 files changed, 32 insertions, 18 deletions
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java index 8a903070..337d3081 100644 --- a/src/main/java/net/minecraft/server/BlockMushroom.java +++ b/src/main/java/net/minecraft/server/BlockMushroom.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.ArrayList; import java.util.Random; // CraftBukkit start +import org.bukkit.BlockChangeDelegate; import org.bukkit.Location; import org.bukkit.TreeType; import org.bukkit.block.BlockState; @@ -109,7 +110,7 @@ public class BlockMushroom extends BlockFlower { worldgenhugemushroom = new WorldGenHugeMushroom(1); } if (worldgenhugemushroom != null && event != null) { - grown = worldgenhugemushroom.grow(world, random, i, j, k, event, itemstack, world.getWorld()); + grown = worldgenhugemushroom.grow((BlockChangeDelegate)world, random, i, j, k, event, itemstack, world.getWorld()); if (event.isFromBonemeal() && itemstack != null) { --itemstack.count; } diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java index 3f437bea..67e727c7 100644 --- a/src/main/java/net/minecraft/server/BlockSapling.java +++ b/src/main/java/net/minecraft/server/BlockSapling.java @@ -78,7 +78,7 @@ public class BlockSapling extends BlockFlower { if (gen == null) { j1 = 0; i1 = 0; - treeType = TreeType.TREE; + treeType = TreeType.SMALL_JUNGLE; gen = new WorldGenTrees(false, 4 + random.nextInt(7), 3, 3, false); } } else { @@ -132,7 +132,7 @@ public class BlockSapling extends BlockFlower { } // CraftBukkit start - interface TreeGenerator { + public interface TreeGenerator { public boolean a(World world, Random random, int i, int j, int k); diff --git a/src/main/java/net/minecraft/server/WorldGenGroundBush.java b/src/main/java/net/minecraft/server/WorldGenGroundBush.java index 3b21c52f..63226648 100644 --- a/src/main/java/net/minecraft/server/WorldGenGroundBush.java +++ b/src/main/java/net/minecraft/server/WorldGenGroundBush.java @@ -4,7 +4,7 @@ import java.util.Random; import org.bukkit.BlockChangeDelegate; // CraftBukkit -public class WorldGenGroundBush extends WorldGenerator { +public class WorldGenGroundBush extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit - add interface private int a; private int b; @@ -49,8 +49,11 @@ public class WorldGenGroundBush extends WorldGenerator { } } } + // CraftBukkit start - return false if gen was unsuccessful + } else { + return false; } - + // CraftBukkit end return true; } } diff --git a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java index 0873320b..23230713 100644 --- a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java +++ b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java @@ -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.block.BlockState; import org.bukkit.craftbukkit.CraftWorld; @@ -9,7 +10,7 @@ import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.material.MaterialData; // CraftBukkit end -public class WorldGenHugeMushroom extends WorldGenerator { +public class WorldGenHugeMushroom extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit - add interface private int a = -1; @@ -22,12 +23,16 @@ public class WorldGenHugeMushroom extends WorldGenerator { super(false); } - // CraftBukkit start - delegate to grow() + // CraftBukkit start - delegate to generate() and use BlockChangeDelegate public boolean a(World world, Random random, int i, int j, int k) { + return grow((BlockChangeDelegate) world, random, i, j, k, null, null, null); + } + + public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) { return grow(world, random, i, j, k, null, null, null); } - public boolean grow(World world, Random random, int i, int j, int k, StructureGrowEvent event, ItemStack itemstack, CraftWorld bukkitWorld) { + public boolean grow(BlockChangeDelegate world, Random random, int i, int j, int k, StructureGrowEvent event, ItemStack itemstack, CraftWorld bukkitWorld) { // CraftBukkit end int l = random.nextInt(2); @@ -71,12 +76,13 @@ public class WorldGenHugeMushroom extends WorldGenerator { j1 = world.getTypeId(i, j - 1, k); if (j1 != Block.DIRT.id && j1 != Block.GRASS.id && j1 != Block.MYCEL.id) { return false; - } else if (!Block.BROWN_MUSHROOM.canPlace(world, i, j, k)) { + // CraftBukkit - Adjust canPlace check to handle non-World BlockChangeDelegates (orig check was: !Block.BROWN_MUSHROOM.canPlace(world, i, j, k)) + } else if ((world.getTypeId(i, j, k) != 0 && !Block.byId[world.getTypeId(i, j, k)].material.isReplacable()) || (world instanceof World && !Block.BROWN_MUSHROOM.canPlace((World) world, i, j, k))) { return false; } else { // CraftBukkit start if (event == null) { - world.setRawTypeIdAndData(i, j - 1, k, Block.DIRT.id, 0); + this.setTypeAndData(world, i, j - 1, k, Block.DIRT.id, 0); } else { BlockState dirtState = bukkitWorld.getBlockAt(i, j - 1, k).getState(); dirtState.setTypeId(Block.DIRT.id); @@ -164,7 +170,7 @@ public class WorldGenHugeMushroom extends WorldGenerator { if ((l2 != 0 || j >= j + i1 - 1) && !Block.n[world.getTypeId(i2, k1, k2)]) { // CraftBukkit start if (event == null) { - world.setRawTypeIdAndData(i2, k1, k2, Block.BIG_MUSHROOM_1.id + l, l2); + this.setTypeAndData(world, i2, k1, k2, Block.BIG_MUSHROOM_1.id + l, l2); } else { BlockState state = bukkitWorld.getBlockAt(i2, k1, k2).getState(); state.setTypeId(Block.BIG_MUSHROOM_1.id + l); @@ -182,7 +188,7 @@ public class WorldGenHugeMushroom extends WorldGenerator { if (!Block.n[l1]) { // CraftBukkit start if (event == null) { - world.setRawTypeIdAndData(i, j + k1, k, Block.BIG_MUSHROOM_1.id + l, 10); + this.setTypeAndData(world, i, j + k1, k, Block.BIG_MUSHROOM_1.id + l, 10); } else { BlockState state = bukkitWorld.getBlockAt(i, j + k1, k).getState(); state.setTypeId(Block.BIG_MUSHROOM_1.id + l); diff --git a/src/main/java/net/minecraft/server/WorldGenSwampTree.java b/src/main/java/net/minecraft/server/WorldGenSwampTree.java index ae4f5446..aac4c035 100644 --- a/src/main/java/net/minecraft/server/WorldGenSwampTree.java +++ b/src/main/java/net/minecraft/server/WorldGenSwampTree.java @@ -2,14 +2,18 @@ package net.minecraft.server; import java.util.Random; -public class WorldGenSwampTree extends WorldGenerator { +public class WorldGenSwampTree extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit - add interface public WorldGenSwampTree() {} public boolean a(World world, Random random, int i, int j, int k) { + return generate((org.bukkit.BlockChangeDelegate) world, random, i, j, k); + } + + public boolean generate(org.bukkit.BlockChangeDelegate world, Random random, int i, int j, int k) { int l; - for (l = random.nextInt(4) + 5; world.getMaterial(i, j - 1, k) == Material.WATER; --j) { + for (l = random.nextInt(4) + 5; world.getTypeId(i, j - 1, k) != 0 && Block.byId[world.getTypeId(i, j - 1, k)].material == Material.WATER; --j) { // CraftBukkit - bypass World.getMaterial ; } @@ -121,7 +125,7 @@ public class WorldGenSwampTree extends WorldGenerator { } } - private void a(World world, int i, int j, int k, int l) { + private void a(org.bukkit.BlockChangeDelegate world, int i, int j, int k, int l) { // CraftBukkit - change signature world.setTypeIdAndData(i, j, k, Block.VINE.id, l); int i1 = 4; diff --git a/src/main/java/net/minecraft/server/WorldGenTrees.java b/src/main/java/net/minecraft/server/WorldGenTrees.java index bc8f8fac..f62ab02c 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -162,7 +162,7 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe // CraftBukkit - Changed world to BlockChangeDelegate private void a(BlockChangeDelegate world, int i, int j, int k, int l) { - ((World)world).setTypeIdAndData(i, j, k, Block.VINE.id, l); // CraftBukkit - Cast + world.setTypeIdAndData(i, j, k, Block.VINE.id, l); int i1 = 4; while (true) { @@ -171,7 +171,7 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe return; } - ((World)world).setRawTypeIdAndData(i, j, k, Block.VINE.id, l); // CraftBukkit - Cast + world.setTypeIdAndData(i, j, k, Block.VINE.id, l); --i1; } } diff --git a/src/main/java/net/minecraft/server/WorldGenerator.java b/src/main/java/net/minecraft/server/WorldGenerator.java index 1a3ad0bc..ae9b7ca6 100644 --- a/src/main/java/net/minecraft/server/WorldGenerator.java +++ b/src/main/java/net/minecraft/server/WorldGenerator.java @@ -23,7 +23,7 @@ public abstract class WorldGenerator { // CraftBukkit - change signature protected void setTypeAndData(BlockChangeDelegate world, int i, int j, int k, int l, int i1) { if (this.a) { - ((World) world).setTypeIdAndData(i, j, k, l, i1); // CraftBukkit - force-cast to world to get it working + world.setTypeIdAndData(i, j, k, l, i1); } else { world.setRawTypeIdAndData(i, j, k, l, i1); } |