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/WorldGenForest.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/WorldGenForest.java')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldGenForest.java | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/src/main/java/net/minecraft/server/WorldGenForest.java b/src/main/java/net/minecraft/server/WorldGenForest.java deleted file mode 100644 index 25f4549a..00000000 --- a/src/main/java/net/minecraft/server/WorldGenForest.java +++ /dev/null @@ -1,109 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.CraftBlockChangeDelegate; // CraftBukkit - -public class WorldGenForest extends WorldGenTreeAbstract implements BlockSapling.TreeGenerator { // CraftBukkit - add interface - - private boolean a; - - public WorldGenForest(boolean flag, boolean flag1) { - super(flag); - this.a = flag1; - } - - public boolean a(World world, Random random, int i, int j, int k) { - // CraftBukkit start - Moved to generate - return this.generate(new CraftBlockChangeDelegate((org.bukkit.BlockChangeDelegate) world), random, i, j, k); - } - - public boolean generate(CraftBlockChangeDelegate world, Random random, int i, int j, int k) { - // CraftBukkit end - int l = random.nextInt(3) + 5; - - if (this.a) { - l += random.nextInt(7); - } - - boolean flag = true; - - if (j >= 1 && j + l + 1 <= 256) { - int i1; - int j1; - - for (int k1 = j; k1 <= j + 1 + l; ++k1) { - byte b0 = 1; - - if (k1 == j) { - b0 = 0; - } - - if (k1 >= j + 1 + l - 2) { - b0 = 2; - } - - for (i1 = i - b0; i1 <= i + b0 && flag; ++i1) { - for (j1 = k - b0; j1 <= k + b0 && flag; ++j1) { - if (k1 >= 0 && k1 < 256) { - Block block = world.getType(i1, k1, j1); - - if (!this.a(block)) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - Block block1 = world.getType(i, j - 1, k); - - if ((block1 == Blocks.GRASS || block1 == Blocks.DIRT || block1 == Blocks.SOIL) && j < 256 - l - 1) { - this.setType(world, i, j - 1, k, Blocks.DIRT); - - int l1; - - for (l1 = j - 3 + l; l1 <= j + l; ++l1) { - i1 = l1 - (j + l); - j1 = 1 - i1 / 2; - - for (int i2 = i - j1; i2 <= i + j1; ++i2) { - int j2 = i2 - i; - - for (int k2 = k - j1; k2 <= k + j1; ++k2) { - int l2 = k2 - k; - - if (Math.abs(j2) != j1 || Math.abs(l2) != j1 || random.nextInt(2) != 0 && i1 != 0) { - Block block2 = world.getType(i2, l1, k2); - - if (block2.getMaterial() == Material.AIR || block2.getMaterial() == Material.LEAVES) { - this.setTypeAndData(world, i2, l1, k2, Blocks.LEAVES, 2); - } - } - } - } - } - - for (l1 = 0; l1 < l; ++l1) { - Block block3 = world.getType(i, j + l1, k); - - if (block3.getMaterial() == Material.AIR || block3.getMaterial() == Material.LEAVES) { - this.setTypeAndData(world, i, j + l1, k, Blocks.LOG, 2); - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } -} |