From 921c354db7247c7e60e5d9d5f6400dbbbf79ce3d Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 23 Jun 2013 21:04:23 +0200 Subject: [PATCH] Made everything that uses canPassThrough use data values. --- .../java/com/sk89q/worldedit/EditSession.java | 8 +++++--- .../java/com/sk89q/worldedit/LocalPlayer.java | 17 +++++++++-------- .../com/sk89q/worldedit/util/TargetBlock.java | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 752939775..105e772ed 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -620,7 +620,8 @@ public class EditSession { for (int y = maxY; y >= minY; --y) { Vector pt = new Vector(x, y, z); int id = getBlockType(pt); - if (naturalOnly ? BlockType.isNaturalTerrainBlock(id) : !BlockType.canPassThrough(id)) { + int data = getBlockData(pt); + if (naturalOnly ? BlockType.isNaturalTerrainBlock(id, data) : !BlockType.canPassThrough(id, data)) { return y; } } @@ -2480,6 +2481,7 @@ public class EditSession { loop: for (int y = world.getMaxY(); y >= 1; --y) { final Vector pt = new Vector(x, y, z); final int id = getBlockType(pt); + final int data = getBlockData(pt); switch (id) { case BlockID.DIRT: @@ -2497,7 +2499,7 @@ public class EditSession { default: // ...and all non-passable blocks - if (!BlockType.canPassThrough(id)) { + if (!BlockType.canPassThrough(id, data)) { break loop; } } @@ -2971,7 +2973,7 @@ public class EditSession { while (!queue.isEmpty()) { final BlockVector current = queue.removeFirst(); - if (!BlockType.canPassThrough(getBlockType(current))) { + if (!BlockType.canPassThrough(getBlockType(current), getBlockData(current))) { continue; } diff --git a/src/main/java/com/sk89q/worldedit/LocalPlayer.java b/src/main/java/com/sk89q/worldedit/LocalPlayer.java index 050cccb34..f14a49a3d 100644 --- a/src/main/java/com/sk89q/worldedit/LocalPlayer.java +++ b/src/main/java/com/sk89q/worldedit/LocalPlayer.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit; import java.io.File; import com.sk89q.worldedit.bags.BlockBag; +import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.ItemID; @@ -79,7 +80,7 @@ public abstract class LocalPlayer { byte free = 0; while (y <= world.getMaxY() + 2) { - if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { + if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { ++free; } else { free = 0; @@ -114,8 +115,8 @@ public abstract class LocalPlayer { while (y >= 0) { final Vector pos = new Vector(x, y, z); final int id = world.getBlockType(pos); - if (!BlockType.canPassThrough(id)) { - final int data = world.getBlockData(pos); + final int data = world.getBlockData(pos); + if (!BlockType.canPassThrough(id, data)) { setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id, data), z + 0.5)); return; } @@ -150,7 +151,7 @@ public abstract class LocalPlayer { byte spots = 0; while (y <= world.getMaxY() + 2) { - if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { + if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { ++free; } else { free = 0; @@ -192,7 +193,7 @@ public abstract class LocalPlayer { byte free = 0; while (y >= 1) { - if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { + if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { ++free; } else { free = 0; @@ -245,7 +246,7 @@ public abstract class LocalPlayer { while (y <= world.getMaxY()) { // Found a ceiling! - if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { + if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { int platformY = Math.max(initialY, y - 3 - clearance); world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS); setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5)); @@ -274,7 +275,7 @@ public abstract class LocalPlayer { LocalWorld world = getPosition().getWorld(); while (y <= world.getMaxY() + 2) { - if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { + if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { break; // Hit something } else if (y > maxY + 1) { break; @@ -488,7 +489,7 @@ public abstract class LocalPlayer { boolean inFree = false; while ((block = hitBlox.getNextBlock()) != null) { - boolean free = BlockType.canPassThrough(world.getBlockType(block)); + boolean free = BlockType.canPassThrough(world.getBlock(block)); if (firstBlock) { firstBlock = false; diff --git a/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/src/main/java/com/sk89q/worldedit/util/TargetBlock.java index 568afacae..44d4aa530 100644 --- a/src/main/java/com/sk89q/worldedit/util/TargetBlock.java +++ b/src/main/java/com/sk89q/worldedit/util/TargetBlock.java @@ -145,7 +145,7 @@ public class TargetBlock { * @return Block */ public BlockWorldVector getSolidTargetBlock() { - while (getNextBlock() != null && BlockType.canPassThrough(world.getBlockType(getCurrentBlock()))) ; + while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock()))) ; return getCurrentBlock(); }