summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordurron597 <martin.jared@gmail.com>2010-12-31 21:17:16 -0500
committerdurron597 <martin.jared@gmail.com>2010-12-31 21:17:16 -0500
commit4af385af1fea94609d89a02a7993778b90fcc4d6 (patch)
tree9542824029a881ba8a8ba5f9f35f538b40492a40
parentd72ecbaf3ffedd03c92e4199d32b34b8e3a4ee9d (diff)
downloadcraftbukkit-4af385af1fea94609d89a02a7993778b90fcc4d6.tar
craftbukkit-4af385af1fea94609d89a02a7993778b90fcc4d6.tar.gz
craftbukkit-4af385af1fea94609d89a02a7993778b90fcc4d6.tar.lz
craftbukkit-4af385af1fea94609d89a02a7993778b90fcc4d6.tar.xz
craftbukkit-4af385af1fea94609d89a02a7993778b90fcc4d6.zip
Reimplemented BlockFlow to use multiple BlockFromToEvents
-rw-r--r--src/net/minecraft/server/BlockFlowing.java49
1 files changed, 20 insertions, 29 deletions
diff --git a/src/net/minecraft/server/BlockFlowing.java b/src/net/minecraft/server/BlockFlowing.java
index 0cef898b..7ab0b64c 100644
--- a/src/net/minecraft/server/BlockFlowing.java
+++ b/src/net/minecraft/server/BlockFlowing.java
@@ -1,12 +1,10 @@
package net.minecraft.server;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Random;
import org.bukkit.BlockFace;
import org.bukkit.event.Event.Type;
-import org.bukkit.event.block.BlockFlowEvent;
+import org.bukkit.event.block.BlockFromToEvent;
public class BlockFlowing extends BlockFluids
{
@@ -90,18 +88,15 @@ public class BlockFlowing extends BlockFluids
if(l(world, i1, j1 - 1, k1))
{
// Craftbucket send "down" to the server
- BlockFlowEvent bfe = new BlockFlowEvent(Type.BLOCK_FLOW, source, BlockFace.Down);
- ((WorldServer) world).callHook(bfe);
+ BlockFromToEvent blockFlow = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.Down);
+ ((WorldServer) world).callHook(blockFlow);
- for (BlockFlowEvent.BlockFlow bf : bfe.getFaces()) {
- if (bf.getFlowDirection().equals(BlockFace.Down) && !bf.isCancelled()) {
- if(l1 >= 8)
- world.b(i1, j1 - 1, k1, bh, l1);
- else
- world.b(i1, j1 - 1, k1, bh, l1 + 8);
- }
- break;
- }
+ if (!blockFlow.isCancelled()) {
+ if(l1 >= 8)
+ world.b(i1, j1 - 1, k1, bh, l1);
+ else
+ world.b(i1, j1 - 1, k1, bh, l1 + 8);
+ }
} else
if(l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1)))
{
@@ -111,22 +106,18 @@ public class BlockFlowing extends BlockFluids
k2 = 1;
if(k2 >= 8)
return;
- // Craftbukkit start
- List<BlockFace> faces = new LinkedList<BlockFace>();
- if(aflag[0])
- faces.add(BlockFace.North);
- if(aflag[1])
- faces.add(BlockFace.South);
- if(aflag[2])
- faces.add(BlockFace.East);
- if(aflag[3])
- faces.add(BlockFace.West);
- BlockFlowEvent bfe = new BlockFlowEvent(Type.BLOCK_FLOW, source, faces);
- ((WorldServer) world).callHook(bfe);
- for (BlockFlowEvent.BlockFlow bf : bfe.getFaces()) {
- if (!bf.isCancelled())
- f(world, i1 + bf.getFlowDirection().getModX(), j1, k1 + bf.getFlowDirection().getModZ(), k2);
+ // Craftbukkit start
+ BlockFace[] faces = new BlockFace[]{ BlockFace.North, BlockFace.South, BlockFace.East, BlockFace.West };
+ for (BlockFace currentFace : faces) {
+ int index = 0;
+ if (aflag[index]) {
+ BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace);
+ ((WorldServer) world).callHook(event);
+ if (!event.isCancelled())
+ f(world, i1 + currentFace.getModX(), j1, k1 + currentFace.getModZ(), k2);
+ }
+ index++;
}
// Craftbukkit stop
}