diff options
author | bloodshot <jdroque@gmail.com> | 2014-01-06 00:17:16 -0500 |
---|---|---|
committer | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2014-04-23 21:25:55 -0600 |
commit | 576758bc55941e673b1c4bf5727a1e1329ef29cd (patch) | |
tree | b3e114f8d5852efafe2827a9a392d11a7ce519f2 /src/main/java/net/minecraft/server/WorldGenHugeMushroom.java | |
parent | de97b62b8945ec7a05c7b6813a6317606f46faaf (diff) | |
download | craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar.gz craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar.lz craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar.xz craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.zip |
Refactored BlockPlaceEvent and BlockChangeDelegate. Adds BUKKIT-5558
23 classes have been removed as they are no longer needed using the new
capture logic. This should help quite a bit with future MC updates.
BlockPlaceEvent Refactor
Before calling Item.interactWith, a recording flag is turned on for
setTypeAndData to capture a blockstate for each block that attempts to be set.
When a block place event is cancelled, the recorded blockstate, stack
size, and metadata will revert back to the captured state. If the event is
not cancelled, a notification will be sent to clients and block physics
will be updated.
BlockChangeDelegate Refactor
Now that we have the ability to capture blockstates through world, there
is no need to modify world gen classes with BlockChangeDelegate. Instead
we will simply capture blocks during world generation in order to "replay"
all of the captured blockstates to send back to delegates.
StructureGrowDelegate and BlockSapling.TreeGenerator have also been
removed as part of this change. BlockSapling and BlockMushroom will
capture blockstates the same as block placement and revert back any grow
events if needed.
Diffstat (limited to 'src/main/java/net/minecraft/server/WorldGenHugeMushroom.java')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldGenHugeMushroom.java | 215 |
1 files changed, 0 insertions, 215 deletions
diff --git a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java deleted file mode 100644 index 67273f21..00000000 --- a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java +++ /dev/null @@ -1,215 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.craftbukkit.CraftBlockChangeDelegate; -import org.bukkit.block.BlockState; -import org.bukkit.material.MaterialData; -// CraftBukkit end - -public class WorldGenHugeMushroom extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit - add interface - - private int a = -1; - - public WorldGenHugeMushroom(int i) { - super(true); - this.a = i; - } - - public WorldGenHugeMushroom() { - super(false); - } - - public boolean a(World world, Random random, int i, int j, int k) { - // CraftBukkit start - Moved to generate - return grow(new CraftBlockChangeDelegate((org.bukkit.BlockChangeDelegate) world), random, i, j, k, null, null, null); - } - - public boolean generate(CraftBlockChangeDelegate world, Random random, int i, int j, int k) { - return grow(world, random, i, j, k, null, null, null); - } - - public boolean grow(CraftBlockChangeDelegate world, Random random, int i, int j, int k, org.bukkit.event.world.StructureGrowEvent event, ItemStack itemstack, org.bukkit.craftbukkit.CraftWorld bukkitWorld) { - // CraftBukkit end - int l = random.nextInt(2); - - if (this.a >= 0) { - l = this.a; - } - - int i1 = random.nextInt(3) + 4; - boolean flag = true; - - if (j >= 1 && j + i1 + 1 < 256) { - int j1; - int k1; - - for (int l1 = j; l1 <= j + 1 + i1; ++l1) { - byte b0 = 3; - - if (l1 <= j + 3) { - b0 = 0; - } - - for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) { - for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) { - if (l1 >= 0 && l1 < 256) { - Block block = world.getType(j1, l1, k1); - - if (block.getMaterial() != Material.AIR && block.getMaterial() != Material.LEAVES) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - Block block1 = world.getType(i, j - 1, k); - - if (block1 != Blocks.DIRT && block1 != Blocks.GRASS && block1 != Blocks.MYCEL) { - return false; - } else { - // CraftBukkit start - if (event == null) { - this.setTypeAndData(world, i, j - 1, k, Blocks.DIRT, 0); - } else { - BlockState dirtState = bukkitWorld.getBlockAt(i, j - 1, k).getState(); - dirtState.setTypeId(Block.b(Blocks.DIRT)); - event.getBlocks().add(dirtState); - } - // CraftBukkit end - - int i2 = j + i1; - - if (l == 1) { - i2 = j + i1 - 3; - } - - for (j1 = i2; j1 <= j + i1; ++j1) { - k1 = 1; - if (j1 < j + i1) { - ++k1; - } - - if (l == 0) { - k1 = 3; - } - - for (int j2 = i - k1; j2 <= i + k1; ++j2) { - for (int k2 = k - k1; k2 <= k + k1; ++k2) { - int l2 = 5; - - if (j2 == i - k1) { - --l2; - } - - if (j2 == i + k1) { - ++l2; - } - - if (k2 == k - k1) { - l2 -= 3; - } - - if (k2 == k + k1) { - l2 += 3; - } - - if (l == 0 || j1 < j + i1) { - if ((j2 == i - k1 || j2 == i + k1) && (k2 == k - k1 || k2 == k + k1)) { - continue; - } - - if (j2 == i - (k1 - 1) && k2 == k - k1) { - l2 = 1; - } - - if (j2 == i - k1 && k2 == k - (k1 - 1)) { - l2 = 1; - } - - if (j2 == i + (k1 - 1) && k2 == k - k1) { - l2 = 3; - } - - if (j2 == i + k1 && k2 == k - (k1 - 1)) { - l2 = 3; - } - - if (j2 == i - (k1 - 1) && k2 == k + k1) { - l2 = 7; - } - - if (j2 == i - k1 && k2 == k + (k1 - 1)) { - l2 = 7; - } - - if (j2 == i + (k1 - 1) && k2 == k + k1) { - l2 = 9; - } - - if (j2 == i + k1 && k2 == k + (k1 - 1)) { - l2 = 9; - } - } - - if (l2 == 5 && j1 < j + i1) { - l2 = 0; - } - - if ((l2 != 0 || j >= j + i1 - 1) && !world.getType(j2, j1, k2).j()) { - // CraftBukkit start - if (event == null) { - this.setTypeAndData(world, j2, j1, k2, Block.e(Block.b(Blocks.BIG_MUSHROOM_1) + l), l2); - } else { - BlockState state = bukkitWorld.getBlockAt(j2, j1, k2).getState(); - state.setTypeId(Block.b(Blocks.BIG_MUSHROOM_1) + l); - state.setData(new MaterialData(Block.b(Blocks.BIG_MUSHROOM_1) + l, (byte) l2)); - event.getBlocks().add(state); - } - // CraftBukkit end - } - } - } - } - - for (j1 = 0; j1 < i1; ++j1) { - Block block2 = world.getType(i, j + j1, k); - - if (!block2.j()) { - // CraftBukkit start - if (event == null) { - this.setTypeAndData(world, i, j + j1, k, Block.e(Block.b(Blocks.BIG_MUSHROOM_1) + l), 10); - } else { - BlockState state = bukkitWorld.getBlockAt(i, j + j1, k).getState(); - state.setTypeId(Block.b(Blocks.BIG_MUSHROOM_1) + l); - state.setData(new MaterialData(Block.b(Blocks.BIG_MUSHROOM_1) + l, (byte) 10)); - event.getBlocks().add(state); - } - // CraftBukkit end - } - } - // CraftBukkit start - if (event != null) { - org.bukkit.Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - for (BlockState state : event.getBlocks()) { - state.update(true); - } - } - } - // CraftBukkit end - return true; - } - } - } else { - return false; - } - } -} |