public boolean targetExists(World var1) { return var1.isLoaded(this.posX, this.posY, this.posZ); }
public static boolean GenerateCustomObject( World world, Random rand, WorldConfig worldSettings, int x, int y, int z, CustomObject workObject, boolean notify) { /* * 1) ground check (moved to ObjectCanSpawn) * 2) add branches and copy all data to work array (dont change default CustomObject object) * 3) collision check and rotation * 4) spawn */ // 1) // 2) int index = 0; int branchLimit = 0; ArrayList<CustomObject> branchGroup = worldSettings.BranchGroups.get(workObject.groupId); ArrayList<Coordinate> workingData = new ArrayList<Coordinate>(); while (index < workObject.Data.size()) { Coordinate DataPoint = workObject.Data.get(index); workingData.add(DataPoint.GetCopy()); if ((DataPoint.branchDirection != -1) && (branchGroup != null) && (branchLimit < workObject.branchLimit)) { CustomObject workingBranch = branchGroup.get(rand.nextInt(branchGroup.size())); int counter = 0; while (counter < workingBranch.Data.size()) { Coordinate untranslatedCoordinate = workingBranch.Data.get(counter).GetCopy(); int directionCounter = 0; while (directionCounter < (DataPoint.branchDirection)) { untranslatedCoordinate.Rotate(); directionCounter++; } workingData.add(untranslatedCoordinate.GetSumm(DataPoint)); counter++; } } index++; } // 3) int RotationAmount = 0; index = 0; int faultCounter = 0; if (workObject.randomRotation) { RotationAmount = rand.nextInt(3); } while (index < workingData.size()) { int counter = 0; Coordinate point = workingData.get(index); while (counter < RotationAmount) { point.Rotate(); counter++; } if (!world.isLoaded(point.getX() + x, point.getY() + y, point.getZ() + z)) return false; if (!workObject.dig) { if (world.getTypeId((x + point.getX()), (y + point.getY()), (z + point.getZ())) > 0) { faultCounter++; if (faultCounter > (workingData.size() * (workObject.collisionPercentage / 100))) { return false; } } } index++; } // 4) index = 0; while (index < workingData.size()) { Coordinate DataPoint = workingData.get(index); if (world.getTypeId(x + DataPoint.getX(), y + DataPoint.getY(), z + DataPoint.getZ()) == 0) { ChangeWorld( world, notify, (x + DataPoint.getX()), y + DataPoint.getY(), z + DataPoint.getZ(), DataPoint.workingData, DataPoint.workingExtra); } else if (DataPoint.Digs) { ChangeWorld( world, notify, (x + DataPoint.getX()), y + DataPoint.getY(), z + DataPoint.getZ(), DataPoint.workingData, DataPoint.workingExtra); } if ((!worldSettings.denyObjectsUnderFill) && (workObject.underFill) && (world.getTypeId(x + DataPoint.getX(), y, z + DataPoint.getZ()) > 0)) { int depthScanner = 0; int blockForFill = world.getTypeId(x, y - 1, z); while (depthScanner < 64) { if (DataPoint.getY() < depthScanner) { int countdown = depthScanner; while ((world.getTypeId( x + DataPoint.getX(), y + DataPoint.getY() - countdown, z + DataPoint.getZ()) == 0) && (countdown < 64)) { ChangeWorld( world, notify, (x + DataPoint.getX()), y + DataPoint.getY() - countdown, z + DataPoint.getZ(), blockForFill, 0); countdown++; } } depthScanner++; } } index++; } return true; }