Commits
durron597 authored 4af385af1fe
1 1 | package net.minecraft.server; |
2 2 | |
3 - | import java.util.LinkedList; |
4 - | import java.util.List; |
5 3 | import java.util.Random; |
6 4 | |
7 5 | import org.bukkit.BlockFace; |
8 6 | import org.bukkit.event.Event.Type; |
9 - | import org.bukkit.event.block.BlockFlowEvent; |
7 + | import org.bukkit.event.block.BlockFromToEvent; |
10 8 | |
11 9 | public class BlockFlowing extends BlockFluids |
12 10 | { |
13 11 | |
14 12 | protected BlockFlowing(int i1, Material material) |
15 13 | { |
16 14 | super(i1, material); |
17 15 | a = 0; |
18 16 | b = new boolean[4]; |
19 17 | c = new int[4]; |
83 81 | { |
84 82 | i(world, i1, j1, k1); |
85 83 | } |
86 84 | |
87 85 | // Craftbukkit start |
88 86 | org.bukkit.Block source = ((WorldServer) world).getWorld().getBlockAt(i1, j1, k1); |
89 87 | |
90 88 | if(l(world, i1, j1 - 1, k1)) |
91 89 | { |
92 90 | // Craftbucket send "down" to the server |
93 - | BlockFlowEvent bfe = new BlockFlowEvent(Type.BLOCK_FLOW, source, BlockFace.Down); |
94 - | ((WorldServer) world).callHook(bfe); |
91 + | BlockFromToEvent blockFlow = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.Down); |
92 + | ((WorldServer) world).callHook(blockFlow); |
95 93 | |
96 - | for (BlockFlowEvent.BlockFlow bf : bfe.getFaces()) { |
97 - | if (bf.getFlowDirection().equals(BlockFace.Down) && !bf.isCancelled()) { |
98 - | if(l1 >= 8) |
99 - | world.b(i1, j1 - 1, k1, bh, l1); |
100 - | else |
101 - | world.b(i1, j1 - 1, k1, bh, l1 + 8); |
102 - | } |
103 - | break; |
104 - | } |
94 + | if (!blockFlow.isCancelled()) { |
95 + | if(l1 >= 8) |
96 + | world.b(i1, j1 - 1, k1, bh, l1); |
97 + | else |
98 + | world.b(i1, j1 - 1, k1, bh, l1 + 8); |
99 + | } |
105 100 | } else |
106 101 | if(l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1))) |
107 102 | { |
108 103 | boolean aflag[] = j(world, i1, j1, k1); |
109 104 | int k2 = l1 + byte0; |
110 105 | if(l1 >= 8) |
111 106 | k2 = 1; |
112 107 | if(k2 >= 8) |
113 108 | return; |
114 - | // Craftbukkit start |
115 - | List<BlockFace> faces = new LinkedList<BlockFace>(); |
116 - | if(aflag[0]) |
117 - | faces.add(BlockFace.North); |
118 - | if(aflag[1]) |
119 - | faces.add(BlockFace.South); |
120 - | if(aflag[2]) |
121 - | faces.add(BlockFace.East); |
122 - | if(aflag[3]) |
123 - | faces.add(BlockFace.West); |
124 109 | |
125 - | BlockFlowEvent bfe = new BlockFlowEvent(Type.BLOCK_FLOW, source, faces); |
126 - | ((WorldServer) world).callHook(bfe); |
127 - | for (BlockFlowEvent.BlockFlow bf : bfe.getFaces()) { |
128 - | if (!bf.isCancelled()) |
129 - | f(world, i1 + bf.getFlowDirection().getModX(), j1, k1 + bf.getFlowDirection().getModZ(), k2); |
110 + | // Craftbukkit start |
111 + | BlockFace[] faces = new BlockFace[]{ BlockFace.North, BlockFace.South, BlockFace.East, BlockFace.West }; |
112 + | for (BlockFace currentFace : faces) { |
113 + | int index = 0; |
114 + | if (aflag[index]) { |
115 + | BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace); |
116 + | ((WorldServer) world).callHook(event); |
117 + | if (!event.isCancelled()) |
118 + | f(world, i1 + currentFace.getModX(), j1, k1 + currentFace.getModZ(), k2); |
119 + | } |
120 + | index++; |
130 121 | } |
131 122 | // Craftbukkit stop |
132 123 | } |
133 124 | } |
134 125 | |
135 126 | private void f(World world, int i1, int j1, int k1, int l1) |
136 127 | { |
137 128 | if(l(world, i1, j1, k1)) |
138 129 | { |
139 130 | int i2 = world.a(i1, j1, k1); |