3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

Reimplemented BlockFlow to use multiple BlockFromToEvents

Dieser Commit ist enthalten in:
durron597 2010-12-31 21:17:16 -05:00
Ursprung d72ecbaf3f
Commit 4af385af1f

Datei anzeigen

@ -1,12 +1,10 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.LinkedList;
import java.util.List;
import java.util.Random; import java.util.Random;
import org.bukkit.BlockFace; import org.bukkit.BlockFace;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockFlowEvent; import org.bukkit.event.block.BlockFromToEvent;
public class BlockFlowing extends BlockFluids public class BlockFlowing extends BlockFluids
{ {
@ -90,18 +88,15 @@ public class BlockFlowing extends BlockFluids
if(l(world, i1, j1 - 1, k1)) if(l(world, i1, j1 - 1, k1))
{ {
// Craftbucket send "down" to the server // Craftbucket send "down" to the server
BlockFlowEvent bfe = new BlockFlowEvent(Type.BLOCK_FLOW, source, BlockFace.Down); BlockFromToEvent blockFlow = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.Down);
((WorldServer) world).callHook(bfe); ((WorldServer) world).callHook(blockFlow);
for (BlockFlowEvent.BlockFlow bf : bfe.getFaces()) { if (!blockFlow.isCancelled()) {
if (bf.getFlowDirection().equals(BlockFace.Down) && !bf.isCancelled()) {
if(l1 >= 8) if(l1 >= 8)
world.b(i1, j1 - 1, k1, bh, l1); world.b(i1, j1 - 1, k1, bh, l1);
else else
world.b(i1, j1 - 1, k1, bh, l1 + 8); world.b(i1, j1 - 1, k1, bh, l1 + 8);
} }
break;
}
} else } else
if(l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1))) if(l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1)))
{ {
@ -111,22 +106,18 @@ public class BlockFlowing extends BlockFluids
k2 = 1; k2 = 1;
if(k2 >= 8) if(k2 >= 8)
return; 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); // Craftbukkit start
((WorldServer) world).callHook(bfe); BlockFace[] faces = new BlockFace[]{ BlockFace.North, BlockFace.South, BlockFace.East, BlockFace.West };
for (BlockFlowEvent.BlockFlow bf : bfe.getFaces()) { for (BlockFace currentFace : faces) {
if (!bf.isCancelled()) int index = 0;
f(world, i1 + bf.getFlowDirection().getModX(), j1, k1 + bf.getFlowDirection().getModZ(), k2); 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 // Craftbukkit stop
} }