Skip to content

Commit

Permalink
Added Block and id/data overloads to canPassThrough, centralTopLimit …
Browse files Browse the repository at this point in the history
…and isNaturalTerrainBlock.
  • Loading branch information
TomyLobo committed Sep 1, 2013
1 parent 43b8c2c commit 756c97d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/main/java/com/sk89q/worldedit/blocks/BlockType.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.foundation.Block;

/**
* Block types.
Expand Down Expand Up @@ -460,16 +461,40 @@ public static boolean shouldPlaceFinal(int id) {
canPassThrough.add(BlockID.CARPET);
}


/**
* Checks whether a block can be passed through.
*
* @param id
* @return
* @deprecated Use {@link #canPassThrough(int,int)} instead
*/
@Deprecated
public static boolean canPassThrough(int id) {
return canPassThrough.contains(id);
}

/**
* Checks whether a block can be passed through.
*
* @param id
* @param data
* @return
*/
public static boolean canPassThrough(int id, int data) {
return canPassThrough.contains(-16*id-data) || canPassThrough.contains(id);
}

/**
* Checks whether a block can be passed through.
*
* @param block
* @return
*/
public static boolean canPassThrough(Block block) {
return canPassThrough(block.getId(), block.getData());
}

/**
* Checks whether a block can be passed through.
*
Expand Down Expand Up @@ -541,6 +566,16 @@ public static double centralTopLimit(int id, int data) {
return canPassThrough(id) ? 0 : 1;
}

/**
* Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5.
*
* @param block
* @return
*/
public static double centralTopLimit(Block block) {
return centralTopLimit(block.getId(), block.getData());
}

/**
* Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5.
*
Expand Down Expand Up @@ -912,6 +947,26 @@ public static boolean isNaturalTerrainBlock(int id) {
return isNaturalTerrainBlock.contains(id);
}

/**
* Checks if the block type is naturally occuring
*
* @param block
* @return
*/
public static boolean isNaturalTerrainBlock(int id, int data) {
return isNaturalTerrainBlock.contains(-16*id-data) || isNaturalTerrainBlock.contains(id);
}

/**
* Checks if the block type is naturally occuring
*
* @param block
* @return
*/
public static boolean isNaturalTerrainBlock(Block block) {
return isNaturalTerrainBlock(block.getId(), block.getData());
}

/**
* Checks if the block type is naturally occuring
*
Expand Down

0 comments on commit 756c97d

Please sign in to comment.