Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///...
- // aG = world, i,j,k = block
- int count = this.countAdjacent(entity.aG, i, j, k);
- ///...
- public int countAdjacent(et world, int i, int j, int k) {
- bk cur = new bk(i, j, k);
- Set<bk> total = new HashSet<bk>();
- total.add(cur);
- this.countAdjacent(world, cur, total);
- return total.size();
- }
- public void countAdjacent(et world, bk cur, Set<bk> total) {
- for(int[] diff: adjdiffs) {
- int nx = cur.a + diff[0];
- int ny = cur.b;
- int nz = cur.c + diff[1];
- if(world.a(nx, ny, nz) == this.bl) {
- bk next = new bk(nx, ny, nz);
- if(total.add(next)) {
- this.countAdjacent(world, next, total);
- }
- }
- }
- }
- public static int[][] adjdiffs = new int[][] {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
Advertisement
Add Comment
Please, Sign In to add comment