Skip to content

Instantly share code, notes, and snippets.

@Draco18s
Last active March 26, 2016 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Draco18s/a1a5d65fe39b8fe85cab to your computer and use it in GitHub Desktop.
Save Draco18s/a1a5d65fe39b8fe85cab to your computer and use it in GitHub Desktop.
public static boolean isBlockUnsupported(World world, int x, int y, int z) {
Block s;
int dir = 0;
int ox = 0;
int oz = 0;
int m;
boolean a, b;
do {
switch(dir) {
case 0:
ox++;
break;
case 1:
oz++;
break;
case 2:
ox--;
break;
case 3:
oz--;
break;
}
s = world.getBlock(x+ox, y, z+oz);
m = world.getBlockMetadata(x+ox, y, z+oz);
a = supportBlocks.indexOf(s) >= 0;
if(HardLibAPI.stoneManager.isUnstableBlock(s,m) && m != 0) {
a = false;
}
//a = a && !(HardLibAPI.stoneManager.isUnstableBlock(s) && m == 0);
s = world.getBlock(x+ox, y-1, z+oz);
m = world.getBlockMetadata(x+ox, y-1, z+oz);
b = supportBlocks.indexOf(s) >= 0;
if(HardLibAPI.stoneManager.isUnstableBlock(s,m) && m != 0) {
b = false;
}
b = b || (world.isBlockNormalCubeDefault(x+ox, y-1, z+oz, true) && world.doesBlockHaveSolidTopSurface(world, x+ox, y-1, z+oz));
if(!a || (ox > maxDist || ox < -maxDist || oz > maxDist || oz < -maxDist)) {
ox = 0;
oz = 0;
dir++;
}
else if(a && b) {
break;
}
} while(dir >= 0 && dir < 4);
if(dir == 4) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment