Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<ChunkCoordinatesBlock> getStructureGenerationPattern(List<ChunkCoordinatesBlock> parData, List<Integer> redundancyData, boolean firstTimeScan, boolean scanForStraitPath) {
- //does the math, needs first time init knowledge
- //if firstTimeScan true, we scan for ground from world data
- //if firstTimeScan false, we use the heightmap to know how far down to scan
- //passes/erases through trees etc from top down scan, hits a proper ground
- //where does air space for walkability through come into play? added in here or outside this? if set here, health calculator could skip it fairly easily
- //pattern config
- double stepDistLength = 0.3D;
- double stepDistThickness = 0.5D;
- double thickness2 = (double)thickness/2D;
- //int lastTopY = this.team.spawn.posY;
- int blockIDGen = getGenBlockBase();
- //List<ChunkCoordinates> data = new ArrayList<ChunkCoordinates>();
- //List<Integer> redundancyData = new ArrayList<Integer>();
- double rot = getAngle();
- //rot = 222;
- if (rot < 0) rot += 360;
- while (rot > 90) rot -= 90;
- double val = Math.max(0.0D, Math.abs(Math.cos(Math.toRadians(rot-45))) * 1.0D);
- //System.out.println(val);
- World world = DimensionManager.getWorld(team.dimID);
- if (world != null) {
- double vecX = posPointEnd.posX - posPointStart.posX;
- double vecY = (posPointEnd.posY+height-1) - (posPointStart.posY+height-1);
- double vecZ = posPointEnd.posZ - posPointStart.posZ;
- if (!scanForStraitPath) {
- vecY = (posPointStart.posY+height-1) - (posPointStart.posY+height-1);
- }
- double dist = (double)Math.sqrt(vecX * vecX + vecY * vecY + vecZ * vecZ);
- for (double curDist = 0 - thickness2; curDist <= dist + thickness2; curDist += stepDistLength) {
- double posX = posPointStart.posX + (vecX / dist * curDist);
- double posY = (posPointStart.posY+height-1) + (vecY / dist * curDist);
- double posZ = posPointStart.posZ + (vecZ / dist * curDist);
- Vec3 vec = Vec3.createVectorHelper(vecX / dist, vecY / dist, vecZ / dist);
- vec.rotateAroundY((float) Math.toRadians(90));
- for (double i = -thickness2; i-stepDistThickness < thickness2; i += stepDistThickness) {
- int posXInt = MathHelper.floor_double(posX + (vec.xCoord * i));
- int posYInt = MathHelper.floor_double(posY);
- int posZInt = MathHelper.floor_double(posZ + (vec.zCoord * i));
- //double posX2 = posX + vec.xCoord * i;
- //double posZ2 = posZ + vec.zCoord * i;
- int topY = 127; //temp default to help debug, fail = its in the air
- if (firstTimeScan) {
- topY = posYInt;
- if (!scanForStraitPath) {
- int id = world.getBlockId(posXInt, topY, posZInt);
- while (id != 0) id = world.getBlockId(posXInt, ++topY, posZInt);
- topY = getTopGroundBlock(world, posXInt, topY, posZInt);
- }
- heightMap.put(ChunkCoordIntPair.chunkXZ2Int(posXInt, posZInt), topY); //has redundant additions, ok because its a hashmap
- } else {
- //ChunkCoordIntPair pair = new ChunkCoordIntPair(MathHelper.floor_double(posX), MathHelper.floor_double(posZ));
- if (heightMap.containsKey(ChunkCoordIntPair.chunkXZ2Int(posXInt, posZInt))) {
- topY = 0+heightMap.get(ChunkCoordIntPair.chunkXZ2Int(posXInt, posZInt)); //why 1+ exactly? where does the y mismatch happen? first gen has a missing y layer, other ones dont
- } else {
- //System.out.println("CRITICAL: MultiLinkedLine getStructureGeneration() heightmap missing data or vector generation changed since firstTimeScan run");
- }
- }
- //downwards gen
- for (int ii = posYInt; ii >= topY; ii--) {
- int id = world.getBlockId(posXInt, ii, posZInt);
- //if (id == 0/*isSafeToGenerateOver(id)*/) {
- ChunkCoordinatesBlock coords = new ChunkCoordinatesBlock(posXInt, ii, posZInt, blockIDGen);
- //System.out.println("coords.hashCode() " + PathPointEx.makeHash(coords.posX, coords.posY, coords.posZ));
- if (!redundancyData.contains(PathPointEx.makeHash(coords.posX, coords.posY, coords.posZ))) {
- parData.add(coords);
- redundancyData.add(PathPointEx.makeHash(coords.posX, coords.posY, coords.posZ));
- }
- //world.setBlock(posXInt, ii, posZInt, blockID);
- //}
- }
- if (curDist > thickness2/2 && curDist < dist - thickness2/2) {
- if (/*i == -thickness2 || */i-val <= -thickness2 || i+stepDistThickness+val >= thickness2) {
- int id = world.getBlockId(posXInt, posYInt+1, posZInt);
- //if (id == 0/*isSafeToGenerateOver(id)*/) {
- ChunkCoordinatesBlock coords = new ChunkCoordinatesBlock(posXInt, posYInt+1, posZInt, getGenBlockRailing());
- if (!redundancyData.contains(PathPointEx.makeHash(coords.posX, coords.posY, coords.posZ))) {
- parData.add(coords);
- redundancyData.add(PathPointEx.makeHash(coords.posX, coords.posY, coords.posZ));
- }
- //}
- }
- }
- //upwards air clearance gen
- for (int ii = posYInt+1; ii < posYInt+1+walkwayYClearance; ii++) {
- int id = world.getBlockId(posXInt, ii, posZInt);
- ChunkCoordinatesBlock coords = new ChunkCoordinatesBlock(posXInt, ii, posZInt, 0);
- if (!redundancyData.contains(PathPointEx.makeHash(coords.posX, coords.posY, coords.posZ))) {
- parData.add(coords);
- redundancyData.add(PathPointEx.makeHash(coords.posX, coords.posY, coords.posZ));
- }
- }
- //railings
- }
- }
- } else {
- System.out.println("critical error world obj null");
- }
- return parData;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement