Skip to content

Commit

Permalink
Made everything that uses canPassThrough use data values.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyLobo committed Jun 23, 2013
1 parent 614a2a2 commit 642c1a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/sk89q/worldedit/EditSession.java
Expand Up @@ -622,8 +622,8 @@ public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, boolean naturalOnly) {
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)) {
BaseBlock block = getBlock(pt);
if (naturalOnly ? BlockType.isNaturalTerrainBlock(block) : !BlockType.canPassThrough(block)) {
return y;
}
}
Expand Down Expand Up @@ -2434,9 +2434,9 @@ public int green(Vector pos, double radius)

loop: for (int y = world.getMaxY(); y >= 1; --y) {
final Vector pt = new Vector(x, y, z);
final int id = getBlockType(pt);
final BaseBlock block = getBlock(pt);

switch (id) {
switch (block.getId()) {
case BlockID.DIRT:
if (setBlock(pt, grass)) {
++affected;
Expand All @@ -2452,7 +2452,7 @@ public int green(Vector pos, double radius)

default:
// ...and all non-passable blocks
if (!BlockType.canPassThrough(id)) {
if (!BlockType.canPassThrough(block)) {
break loop;
}
}
Expand Down Expand Up @@ -2922,7 +2922,7 @@ private void recurseHollow(Region region, BlockVector origin, Set<BlockVector> o

while (!queue.isEmpty()) {
final BlockVector current = queue.removeFirst();
if (!BlockType.canPassThrough(getBlockType(current))) {
if (!BlockType.canPassThrough(getBlock(current))) {
continue;
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/sk89q/worldedit/LocalPlayer.java
Expand Up @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -79,7 +80,7 @@ public void findFreePosition(WorldVector searchPos) {
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;
Expand Down Expand Up @@ -113,10 +114,9 @@ public void setOnGround(WorldVector searchPos) {

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);
setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id, data), z + 0.5));
final BaseBlock block = world.getBlock(pos);
if (!BlockType.canPassThrough(block)) {
setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(block), z + 0.5));
return;
}

Expand Down Expand Up @@ -150,7 +150,7 @@ public boolean ascendLevel() {
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;
Expand Down Expand Up @@ -192,7 +192,7 @@ public boolean descendLevel() {
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;
Expand Down Expand Up @@ -245,7 +245,7 @@ public boolean ascendToCeiling(int clearance) {

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));
Expand Down Expand Up @@ -274,7 +274,7 @@ public boolean ascendUpwards(int distance) {
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;
Expand Down Expand Up @@ -488,7 +488,7 @@ public boolean passThroughForwardWall(int range) {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/sk89q/worldedit/util/TargetBlock.java
Expand Up @@ -145,7 +145,7 @@ public BlockWorldVector getTargetBlock() {
* @return Block
*/
public BlockWorldVector getSolidTargetBlock() {
while (getNextBlock() != null && BlockType.canPassThrough(world.getBlockType(getCurrentBlock()))) ;
while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock()))) ;
return getCurrentBlock();
}

Expand Down

0 comments on commit 642c1a6

Please sign in to comment.