diff options
author | speakeasy <mekevin1917@gmail.com> | 2011-01-11 05:07:56 +0800 |
---|---|---|
committer | tahg <tahgtahv@gmail.com> | 2011-01-11 05:25:09 +0800 |
commit | 802a46a7097354fe40a6502edc5357e105e84fc3 (patch) | |
tree | e529ea463ec0f9f48d42b45189d26d41b25524a4 /src/main/java/net/minecraft/server/BlockFire.java | |
parent | 136ad76e6ac7316825cbbd2b19fc03a67a20f5b9 (diff) | |
download | craftbukkit-802a46a7097354fe40a6502edc5357e105e84fc3.tar craftbukkit-802a46a7097354fe40a6502edc5357e105e84fc3.tar.gz craftbukkit-802a46a7097354fe40a6502edc5357e105e84fc3.tar.lz craftbukkit-802a46a7097354fe40a6502edc5357e105e84fc3.tar.xz craftbukkit-802a46a7097354fe40a6502edc5357e105e84fc3.zip |
Added hooks for BlockIgniteEvent
Signed-off-by: speakeasy <mekevin1917@gmail.com>
Diffstat (limited to 'src/main/java/net/minecraft/server/BlockFire.java')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockFire.java | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java new file mode 100644 index 00000000..a0871334 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockFire.java @@ -0,0 +1,212 @@ +package net.minecraft.server; + +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import java.util.Random; + + +public class BlockFire extends Block { + + private int a[]; + private int b[]; + + protected BlockFire(int i, int j) { + super(i, j, Material.l); + a = new int[256]; + b = new int[256]; + a(Block.x.bh, 5, 20); + a(Block.J.bh, 5, 5); + a(Block.K.bh, 30, 60); + a(Block.an.bh, 30, 20); + a(Block.am.bh, 15, 100); + a(Block.ab.bh, 30, 60); + a(true); + } + + private void a(int i, int j, int k) { + a[i] = j; + b[i] = k; + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean a() { + return false; + } + + public int a(Random random) { + return 0; + } + + public int b() { + return 10; + } + + @Override + public void a(World world, int i, int j, int k, Random random) { + boolean flag = world.a(i, j - 1, k) == Block.bb.bh; + int ll = world.b(i, j, k); + + if (ll < 15) { + world.b(i, j, k, ll + 1); + world.h(i, j, k, bh); + } + if (!flag && !g(world, i, j, k)) { + if (!world.d(i, j - 1, k) || ll > 3) { + world.d(i, j, k, 0); + } + return; + } + // CraftBukkit: Cast to fix compile errors. + if ((i == 0) && (!b((IBlockAccess)world, i, j - 1, k)) && ll == 15 && (random.nextInt(4) == 0)) { + world.d(i, j, k, 0); + return; + } + if (ll % 2 == 0 && ll > 2) { + a(world, i + 1, j, k, 300, random); + a(world, i - 1, j, k, 300, random); + a(world, i, j - 1, k, 250, random); + a(world, i, j + 1, k, 250, random); + a(world, i, j, k - 1, 300, random); + a(world, i, j, k + 1, 300, random); + for (int i1 = i - 1; i1 <= i + 1; i1++) { + for (int j1 = k - 1; j1 <= k + 1; j1++) { + for (int k1 = j - 1; k1 <= j + 4; k1++) { + if (i1 == i && k1 == j && j1 == k) { + continue; + } + int l1 = 100; + + if (k1 > j + 1) { + l1 += (k1 - (j + 1)) * 100; + } + int i2 = h(world, i1, k1, j1); + + // CraftBukkit: Call to stop spead of fire. + CraftServer server = ((WorldServer)world).getServer(); + CraftWorld cworld = ((WorldServer) world).getWorld(); + org.bukkit.Block bblock = (cworld.getBlockAt(i1, k1, j1)); + BlockIgniteEvent event = new BlockIgniteEvent((org.bukkit.Block) bblock, BlockIgniteEvent.IgniteCause.SPREAD, null); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + if (i2 > 0 && random.nextInt(l1) <= i2) { + world.d(i1, k1, j1, bh); + } + } + } + } + } + } + + private void a(World world, int i, int j, int k, int l, Random random) { + int i1 = b[world.a(i, j, k)]; + + if (random.nextInt(l) < i1) { + boolean flag = world.a(i, j, k) == Block.am.bh ? true : false; + + if (random.nextInt(2) == 0) { + // CraftBukkit: Call to stop very slow spread of fire. + CraftServer server = ((WorldServer)world).getServer(); + CraftWorld cworld = ((WorldServer)world).getWorld(); + org.bukkit.Block sbblock = (cworld.getBlockAt(i, j, k)); + BlockIgniteEvent event = new BlockIgniteEvent((org.bukkit.Block) sbblock, BlockIgniteEvent.IgniteCause.SLOW_SPREAD, null); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + world.d(i, j, k, bh); + } else { + world.d(i, j, k, 0); + } + if (flag) { + Block.am.a(world, i, j, k, 0); + } + } + } + + private boolean g(World world, int i, int j, int k) { + // CraftBukkit: Cast to correct compile errors 6 times. + if (b((IBlockAccess)world, i + 1, j, k)) { + return true; + } + if (b((IBlockAccess)world, i - 1, j, k)) { + return true; + } + if (b((IBlockAccess)world, i, j - 1, k)) { + return true; + } + if (b((IBlockAccess)world, i, j + 1, k)) { + return true; + } + if (b((IBlockAccess)world, i, j, k - 1)) { + return true; + } + return b((IBlockAccess)world, i, j, k + 1); + } + + private int h(World world, int i, int j, int k) { + int l = 0; + + if (!world.e(i, j, k)) { + return 0; + } else { + l = f(world, i + 1, j, k, l); + l = f(world, i - 1, j, k, l); + l = f(world, i, j - 1, k, l); + l = f(world, i, j + 1, k, l); + l = f(world, i, j, k - 1, l); + l = f(world, i, j, k + 1, l); + return l; + } + } + + public boolean d() { + return false; + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { + return a[iblockaccess.a(i, j, k)] > 0; + } + + public int f(World world, int i, int j, int k, int l) { + int i1 = a[world.a(i, j, k)]; + + if (i1 > l) { + return i1; + } else { + return l; + } + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i, j - 1, k) || g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (!world.d(i, j - 1, k) && !g(world, i, j, k)) { + world.d(i, j, k, 0); + return; + } else { + return; + } + } + + public void e(World world, int i, int j, int k) { + if (world.a(i, j - 1, k) == Block.ap.bh && Block.be.a_(world, i, j, k)) { + return; + } + if (!world.d(i, j - 1, k) && !g(world, i, j, k)) { + world.d(i, j, k, 0); + return; + } else { + world.h(i, j, k, bh); + return; + } + } +} + |