Made everything that uses canPassThrough use data values.

This commit is contained in:
TomyLobo 2013-06-23 21:04:23 +02:00
parent b612de3429
commit 921c354db7
3 changed files with 15 additions and 12 deletions

View File

@ -620,7 +620,8 @@ public class EditSession {
for (int y = maxY; y >= minY; --y) { for (int y = maxY; y >= minY; --y) {
Vector pt = new Vector(x, y, z); Vector pt = new Vector(x, y, z);
int id = getBlockType(pt); 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; return y;
} }
} }
@ -2480,6 +2481,7 @@ public class EditSession {
loop: for (int y = world.getMaxY(); y >= 1; --y) { loop: for (int y = world.getMaxY(); y >= 1; --y) {
final Vector pt = new Vector(x, y, z); final Vector pt = new Vector(x, y, z);
final int id = getBlockType(pt); final int id = getBlockType(pt);
final int data = getBlockData(pt);
switch (id) { switch (id) {
case BlockID.DIRT: case BlockID.DIRT:
@ -2497,7 +2499,7 @@ public class EditSession {
default: default:
// ...and all non-passable blocks // ...and all non-passable blocks
if (!BlockType.canPassThrough(id)) { if (!BlockType.canPassThrough(id, data)) {
break loop; break loop;
} }
} }
@ -2971,7 +2973,7 @@ public class EditSession {
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
final BlockVector current = queue.removeFirst(); final BlockVector current = queue.removeFirst();
if (!BlockType.canPassThrough(getBlockType(current))) { if (!BlockType.canPassThrough(getBlockType(current), getBlockData(current))) {
continue; continue;
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit;
import java.io.File; import java.io.File;
import com.sk89q.worldedit.bags.BlockBag; import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemID; import com.sk89q.worldedit.blocks.ItemID;
@ -79,7 +80,7 @@ public abstract class LocalPlayer {
byte free = 0; byte free = 0;
while (y <= world.getMaxY() + 2) { 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; ++free;
} else { } else {
free = 0; free = 0;
@ -114,8 +115,8 @@ public abstract class LocalPlayer {
while (y >= 0) { while (y >= 0) {
final Vector pos = new Vector(x, y, z); final Vector pos = new Vector(x, y, z);
final int id = world.getBlockType(pos); 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)); setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id, data), z + 0.5));
return; return;
} }
@ -150,7 +151,7 @@ public abstract class LocalPlayer {
byte spots = 0; byte spots = 0;
while (y <= world.getMaxY() + 2) { 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; ++free;
} else { } else {
free = 0; free = 0;
@ -192,7 +193,7 @@ public abstract class LocalPlayer {
byte free = 0; byte free = 0;
while (y >= 1) { while (y >= 1) {
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
++free; ++free;
} else { } else {
free = 0; free = 0;
@ -245,7 +246,7 @@ public abstract class LocalPlayer {
while (y <= world.getMaxY()) { while (y <= world.getMaxY()) {
// Found a ceiling! // 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); int platformY = Math.max(initialY, y - 3 - clearance);
world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS); world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS);
setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5)); setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5));
@ -274,7 +275,7 @@ public abstract class LocalPlayer {
LocalWorld world = getPosition().getWorld(); LocalWorld world = getPosition().getWorld();
while (y <= world.getMaxY() + 2) { 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 break; // Hit something
} else if (y > maxY + 1) { } else if (y > maxY + 1) {
break; break;
@ -488,7 +489,7 @@ public abstract class LocalPlayer {
boolean inFree = false; boolean inFree = false;
while ((block = hitBlox.getNextBlock()) != null) { while ((block = hitBlox.getNextBlock()) != null) {
boolean free = BlockType.canPassThrough(world.getBlockType(block)); boolean free = BlockType.canPassThrough(world.getBlock(block));
if (firstBlock) { if (firstBlock) {
firstBlock = false; firstBlock = false;

View File

@ -145,7 +145,7 @@ public class TargetBlock {
* @return Block * @return Block
*/ */
public BlockWorldVector getSolidTargetBlock() { public BlockWorldVector getSolidTargetBlock() {
while (getNextBlock() != null && BlockType.canPassThrough(world.getBlockType(getCurrentBlock()))) ; while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock()))) ;
return getCurrentBlock(); return getCurrentBlock();
} }