(Position p, int material)
| 12 | } |
| 13 | |
| 14 | @Override |
| 15 | public void add(Position p, int material) { |
| 16 | Position bestXY = this.cuboidFinder.getBestXY(p, material); |
| 17 | Position bestYZ = this.cuboidFinder.getBestYZ(p, material); |
| 18 | int sizeXY = p.getRoomSizeTo(bestXY); |
| 19 | int sizeYZ = p.getRoomSizeTo(bestYZ); |
| 20 | int parts = 16; |
| 21 | int yOffset = 0; |
| 22 | int yStop = 0; |
| 23 | int xOffset = 0; |
| 24 | int zOffset = 0; |
| 25 | int xStop = 0; |
| 26 | int zStop = 0; |
| 27 | Position end; |
| 28 | if (sizeXY > sizeYZ) { // window in x,y direction |
| 29 | end = bestXY; |
| 30 | zOffset = 7; |
| 31 | zStop = 7; |
| 32 | } else if (sizeXY < sizeYZ) { // window in z,y direction |
| 33 | end = bestYZ; |
| 34 | xOffset = 7; |
| 35 | xStop = 7; |
| 36 | } else { // check for borders |
| 37 | int x = p.getX(); |
| 38 | int y = p.getY(); |
| 39 | int z = p.getZ(); |
| 40 | int sumX = this.countAirY(x + 1, y, z, bestXY.getY()) + this.countAirY(x - 1, y, z, bestXY.getY()); |
| 41 | int sumZ = this.countAirY(x, y, z + 1, bestYZ.getY()) + this.countAirY(x, y, z - 1, bestYZ.getY()); |
| 42 | if (sumX <= sumZ) { |
| 43 | end = bestXY; |
| 44 | zOffset = 7; |
| 45 | zStop = 7; |
| 46 | } else { |
| 47 | end = bestYZ; |
| 48 | xOffset = 7; |
| 49 | xStop = 7; |
| 50 | } |
| 51 | } |
| 52 | Position offset = new Position(xOffset, yOffset, zOffset); |
| 53 | Position negativeOffset = new Position(xStop, yStop, zStop); |
| 54 | this.map.addDetail(this.map.createCuboid(p, end, parts, offset, negativeOffset, material)); |
| 55 | this.map.markAsConverted(p, end); |
| 56 | } |
| 57 | |
| 58 | private int countAirY(int x, int yStart, int z, int yEnd) { |
| 59 | int sum = 0; |
nothing calls this directly
no test coverage detected