UtilBlock: Modified getInRadius() to allow option of a hollow sphere

This commit is contained in:
libraryaddict 2015-04-03 19:34:24 +13:00
parent 6faf5011a8
commit 05319511ff
1 changed files with 10 additions and 2 deletions

View File

@ -304,7 +304,13 @@ public class UtilBlock
return blockList; return blockList;
} }
public static HashMap<Block, Double> getInRadius(Block block, double dR) public static HashMap<Block, Double> getInRadius(Block block, double dR)
{
return getInRadius(block, dR, false);
}
public static HashMap<Block, Double> getInRadius(Block block, double dR, boolean hollow)
{ {
HashMap<Block, Double> blockList = new HashMap<Block, Double>(); HashMap<Block, Double> blockList = new HashMap<Block, Double>();
int iR = (int)dR + 1; int iR = (int)dR + 1;
@ -317,8 +323,10 @@ public class UtilBlock
double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation()); double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation());
if (offset <= dR) if (offset <= dR && !(hollow && offset < dR - 1))
blockList.put(curBlock, 1 - (offset/dR)); {
blockList.put(curBlock, 1 - (offset / dR));
}
} }
return blockList; return blockList;