use of com.mcmoddev.orespawn.api.os3.ISpawnEntry in project OreSpawn by MinecraftModDevelopmentMods.
the class FeatureBase method spawnMungeSW.
protected void spawnMungeSW(World world, BlockPos blockPos, int rSqr, double radius, ISpawnEntry spawnData, int count) {
Random prng = this.random;
int quantity = count;
IBlockList possibleOres = spawnData.getBlocks();
OreSpawnBlockMatcher replacer = spawnData.getMatcher();
for (int dy = (int) (-1 * radius); dy < radius; dy++) {
for (int dx = (int) (radius); dx >= (int) (-1 * radius); dx--) {
for (int dz = (int) (radius); dz >= (int) (-1 * radius); dz--) {
if ((dx * dx + dy * dy + dz * dz) <= rSqr) {
IBlockState oreBlock = possibleOres.getRandomBlock(prng);
spawnOrCache(world, blockPos.add(dx, dy, dz), replacer, oreBlock, true, world.provider.getDimension(), spawnData);
quantity--;
}
if (quantity <= 0) {
return;
}
}
}
}
}
use of com.mcmoddev.orespawn.api.os3.ISpawnEntry in project OreSpawn by MinecraftModDevelopmentMods.
the class OreSpawnWriter method saveSingle.
private static void saveSingle(Path filePath, Gson gson) {
JsonObject root = new JsonObject();
root.addProperty(ConfigNames.FILE_VERSION, "2.0");
JsonObject spawns = new JsonObject();
String k = filePath.getFileName().toString();
Path saveDir = Constants.CONFDIR.resolve("forced-saves");
Path conf = saveDir.resolve(k);
if (!saveDir.toFile().exists()) {
saveDir.toFile().mkdirs();
}
try (BufferedWriter p = Files.newBufferedWriter(conf, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) {
OreSpawn.API.getSpawnsForFile(k).stream().forEach(spawnName -> {
JsonObject thisSpawn = new JsonObject();
ISpawnEntry spawnEntry = OreSpawn.API.getSpawn(spawnName);
thisSpawn.addProperty(ConfigNames.ENABLED, spawnEntry.isEnabled());
thisSpawn.addProperty(ConfigNames.RETROGEN, spawnEntry.isRetrogen());
thisSpawn.addProperty(ConfigNames.FEATURE, spawnEntry.getFeature().getFeatureName());
thisSpawn.add(ConfigNames.DIMENSIONS, spawnEntry.getDimensions().serialize());
thisSpawn.add(ConfigNames.BIOMES, spawnEntry.getBiomes().serialize());
thisSpawn.add(ConfigNames.REPLACEMENT, spawnEntry.getMatcher().serialize());
thisSpawn.add(ConfigNames.PARAMETERS, spawnEntry.getFeature().getFeatureParameters());
spawns.add(spawnName, thisSpawn);
});
root.add(ConfigNames.SPAWNS, spawns);
p.write(gson.toJson(root));
} catch (IOException e) {
CrashReport report = CrashReport.makeCrashReport(e, "Failed writing config data " + conf.toString());
report.getCategory().addCrashSection("OreSpawn Version", Constants.VERSION);
OreSpawn.LOGGER.info(report.getCompleteReport());
}
}
use of com.mcmoddev.orespawn.api.os3.ISpawnEntry in project OreSpawn by MinecraftModDevelopmentMods.
the class FeatureBase method spawnMungeNE.
protected void spawnMungeNE(World world, BlockPos blockPos, int rSqr, double radius, ISpawnEntry spawnData, int count) {
Random prng = this.random;
int quantity = count;
IBlockList possibleOres = spawnData.getBlocks();
OreSpawnBlockMatcher replacer = spawnData.getMatcher();
for (int dy = (int) (-1 * radius); dy < radius; dy++) {
for (int dz = (int) (-1 * radius); dz < radius; dz++) {
for (int dx = (int) (-1 * radius); dx < radius; dx++) {
if ((dx * dx + dy * dy + dz * dz) <= rSqr) {
IBlockState oreBlock = possibleOres.getRandomBlock(prng);
spawnOrCache(world, blockPos.add(dx, dy, dz), replacer, oreBlock, true, world.provider.getDimension(), spawnData);
quantity--;
}
if (quantity <= 0) {
return;
}
}
}
}
}
Aggregations