Skip to content

Instantly share code, notes, and snippets.

@hilburn
Last active August 29, 2015 14:21
Show Gist options
  • Save hilburn/aa89ff462c94ed2496ce to your computer and use it in GitHub Desktop.
Save hilburn/aa89ff462c94ed2496ce to your computer and use it in GitHub Desktop.
private boolean checkHorizontal(World world, int x, int y, int z) {
ForgeDirection[] VALID_DIRECTIONS = new ForgeDirection[] {
ForgeDirection.NORTH, ForgeDirection.SOUTH,
ForgeDirection.EAST, ForgeDirection.WEST };
for (ForgeDirection dir : VALID_DIRECTIONS) {
int newX = x + dir.offsetX;
int newZ = z + dir.offsetZ;
//Checks adjacent blocks
if (world.getBlock(newX, y, newZ) != Register.BlockMaterials
|| world.getBlockMetadata(newX, y, newZ) != 1) {
return false;
}
//Checks blocks 2 away on the NS and EW axes
if (world.getBlock(newX + dir.offsetX, y, newZ + dir.offsetZ) != Register.BlockXenolith
|| world.getBlockMetadata(newX + dir.offsetX, y, newZ + dir.offsetZ) != 0) {
return false;
}
}
for (int dx = -2; dx <= 2; dx +=4)
{
for (int dz = -2; dz <= 2; dz +=4)
{
//x + dx, z + dz gives the 4 coordinates of the pillar bases
for (int dy = 0; dy < 3; dy++)
{
//Loops up the pillar and checks for the first 3 blocks
if(world.getBlock(x + dx, y + dy, z + dz) != Register.BlockXenolith
|| world.getBlockMetadata(x + dx, y + dy, z + dz) != 0){
return false;
}
}
//Checks the top block of the pillar
if(world.getBlock(x + dx, y + 3, z + dz) != Register.BlockXenolith
|| world.getBlockMetadata(x + dx, y + 3, z + dz) != 6){
return false;
}
//x + dx/2, z + dz/2 is the location of the block diagonally closer to the centre from the pillar
if (world.getBlock(x + dx/2, y, z + dz/2) != Register.BlockXenolith
|| world.getBlockMetadata(x + dx/2, y, z + dz/2) != 0) {
return false;
}
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment