MCPcopy Create free account
hub / github.com/Garten/sourcecraft / add

Method add

src/source/addable/addable/Pane.java:14–56  ·  view source on GitHub ↗
(Position p, int material)

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 10

getYMethod · 0.95
countAirYMethod · 0.95
getRoomSizeToMethod · 0.80
getBestXYMethod · 0.65
getBestYZMethod · 0.65
addDetailMethod · 0.65
createCuboidMethod · 0.65
markAsConvertedMethod · 0.65
getXMethod · 0.45
getZMethod · 0.45

Tested by

no test coverage detected