summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/WorldGenSwampTree.java
diff options
context:
space:
mode:
authorbloodshot <jdroque@gmail.com>2014-01-06 00:17:16 -0500
committerNate Mortensen <nate.richard.mortensen@gmail.com>2014-04-23 21:25:55 -0600
commit576758bc55941e673b1c4bf5727a1e1329ef29cd (patch)
treeb3e114f8d5852efafe2827a9a392d11a7ce519f2 /src/main/java/net/minecraft/server/WorldGenSwampTree.java
parentde97b62b8945ec7a05c7b6813a6317606f46faaf (diff)
downloadcraftbukkit-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/WorldGenSwampTree.java')
-rw-r--r--src/main/java/net/minecraft/server/WorldGenSwampTree.java151
1 files changed, 0 insertions, 151 deletions
diff --git a/src/main/java/net/minecraft/server/WorldGenSwampTree.java b/src/main/java/net/minecraft/server/WorldGenSwampTree.java
deleted file mode 100644
index 3f051648..00000000
--- a/src/main/java/net/minecraft/server/WorldGenSwampTree.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package net.minecraft.server;
-
-import java.util.Random;
-
-import org.bukkit.craftbukkit.CraftBlockChangeDelegate; // CraftBukkit
-
-public class WorldGenSwampTree extends WorldGenTreeAbstract implements BlockSapling.TreeGenerator { // CraftBukkit - add interface
-
- public WorldGenSwampTree() {
- super(false);
- }
-
- 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;
-
- for (l = random.nextInt(4) + 5; world.getType(i, j - 1, k).getMaterial() == Material.WATER; --j) {
- ;
- }
-
- 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 = 3;
- }
-
- 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 (block.getMaterial() != Material.AIR && block.getMaterial() != Material.LEAVES) {
- if (block != Blocks.STATIONARY_WATER && block != Blocks.WATER) {
- flag = false;
- } else if (k1 > j) {
- 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) && j < 256 - l - 1) {
- this.setType(world, i, j - 1, k, Blocks.DIRT);
-
- int l1;
- int i2;
- int j2;
-
- for (j2 = j - 3 + l; j2 <= j + l; ++j2) {
- i1 = j2 - (j + l);
- j1 = 2 - i1 / 2;
-
- for (i2 = i - j1; i2 <= i + j1; ++i2) {
- l1 = i2 - i;
-
- for (int k2 = k - j1; k2 <= k + j1; ++k2) {
- int l2 = k2 - k;
-
- if ((Math.abs(l1) != j1 || Math.abs(l2) != j1 || random.nextInt(2) != 0 && i1 != 0) && !world.getType(i2, j2, k2).j()) {
- this.setType(world, i2, j2, k2, Blocks.LEAVES);
- }
- }
- }
- }
-
- for (j2 = 0; j2 < l; ++j2) {
- Block block2 = world.getType(i, j + j2, k);
-
- if (block2.getMaterial() == Material.AIR || block2.getMaterial() == Material.LEAVES || block2 == Blocks.WATER || block2 == Blocks.STATIONARY_WATER) {
- this.setType(world, i, j + j2, k, Blocks.LOG);
- }
- }
-
- for (j2 = j - 3 + l; j2 <= j + l; ++j2) {
- i1 = j2 - (j + l);
- j1 = 2 - i1 / 2;
-
- for (i2 = i - j1; i2 <= i + j1; ++i2) {
- for (l1 = k - j1; l1 <= k + j1; ++l1) {
- if (world.getType(i2, j2, l1).getMaterial() == Material.LEAVES) {
- if (random.nextInt(4) == 0 && world.getType(i2 - 1, j2, l1).getMaterial() == Material.AIR) {
- this.a(world, i2 - 1, j2, l1, 8);
- }
-
- if (random.nextInt(4) == 0 && world.getType(i2 + 1, j2, l1).getMaterial() == Material.AIR) {
- this.a(world, i2 + 1, j2, l1, 2);
- }
-
- if (random.nextInt(4) == 0 && world.getType(i2, j2, l1 - 1).getMaterial() == Material.AIR) {
- this.a(world, i2, j2, l1 - 1, 1);
- }
-
- if (random.nextInt(4) == 0 && world.getType(i2, j2, l1 + 1).getMaterial() == Material.AIR) {
- this.a(world, i2, j2, l1 + 1, 4);
- }
- }
- }
- }
- }
-
- return true;
- } else {
- return false;
- }
- }
- } else {
- return false;
- }
- }
-
- // CraftBukkit - change signature
- private void a(CraftBlockChangeDelegate world, int i, int j, int k, int l) {
- this.setTypeAndData(world, i, j, k, Blocks.VINE, l);
- int i1 = 4;
-
- while (true) {
- --j;
- if (world.getType(i, j, k).getMaterial() != Material.AIR || i1 <= 0) {
- return;
- }
-
- this.setTypeAndData(world, i, j, k, Blocks.VINE, l);
- --i1;
- }
- }
-}