use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.
the class CommandRetrogen method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
Predicate<Structure> structurePredicate = parameters.get("exp").to(RCP::structurePredicate).optional().orElse(null);
WorldServer world = parameters.get("dimension").to(MCP.dimension(server, commandSender)).require();
long count = retrogen(world, structurePredicate);
commandSender.sendMessage(RecurrentComplex.translations.format("commands.rcretro.count", String.valueOf(count)));
}
use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.
the class CommandSightInfo method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
WorldStructureGenerationData generationData = WorldStructureGenerationData.get(sender.getEntityWorld());
WorldStructureGenerationData.Entry entry = generationData.getEntry(UUID.fromString(parameters.get(0).require()));
if (entry == null)
throw RecurrentComplex.translations.commandException("commands.rcsightinfo.unknown");
else {
ITextComponent area = RCTextStyle.area(RCBlockAreas.from(entry.getBoundingBox()));
ITextComponent sight = RCTextStyle.sight(entry, true);
if (entry instanceof WorldStructureGenerationData.StructureEntry) {
WorldStructureGenerationData.StructureEntry structureEntry = (WorldStructureGenerationData.StructureEntry) entry;
sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.structure", RCTextStyle.structure(structureEntry.getStructureID()), area, RCTextStyle.copy(String.valueOf(structureEntry.getSeed())), sight));
Structure structure = StructureRegistry.INSTANCE.get(structureEntry.getStructureID());
if (structure != null) {
// TODO generateAsSource not accurate
NBTStorable instanceData = structure.loadInstanceData(new StructureLoadContext(structureEntry.getTransform(), entry.getBoundingBox(), false), structureEntry.getInstanceData(), RCConfig.getUniversalTransformer());
List<TextComponentBase> list = structure.instanceDataInfo(instanceData);
for (TextComponentBase s : list) sender.sendMessage(s);
}
} else
sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.get", entry.description(), area, sight));
}
}
use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.
the class GenericVillageCreationHandler method buildComponent.
@Override
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int x, int y, int z, EnumFacing front, int generationDepth) {
Structure structure = StructureRegistry.INSTANCE.get(structureID);
if (structure == null)
return kill(villagePiece);
GenerationType generationType = structure.generationType(generationID);
if (!(generationType instanceof VanillaGeneration))
return kill(villagePiece);
VanillaGeneration vanillaGenInfo = (VanillaGeneration) generationType;
AxisAlignedTransform2D transform = GenericVillagePiece.getTransform(vanillaGenInfo.front, structure.isMirrorable(), structure.isRotatable(), front.getOpposite(), random);
if (!vanillaGenInfo.generatesIn(startPiece.biome) || transform == null)
return kill(villagePiece);
int[] structureSize = RCAxisAlignedTransform.applySize(transform, structure.size());
StructureBoundingBox strucBB = Structures.boundingBox(new BlockPos(x, y, z), structureSize);
if (!GenericVillagePiece.canVillageGoDeeperC(strucBB) || StructureComponent.findIntersecting(pieces, strucBB) != null)
return null;
GenericVillagePiece genericVillagePiece = GenericVillagePiece.create(structureID, generationID, startPiece, generationDepth);
genericVillagePiece.seed = random.nextLong();
if (genericVillagePiece == null)
return kill(villagePiece);
genericVillagePiece.setIds(structureID, generationID);
genericVillagePiece.setOrientation(front, transform, strucBB);
return genericVillagePiece;
}
use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.
the class CommandSanity method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
boolean sane = true;
if (RecurrentComplex.isLite()) {
commandSender.sendMessage(new TextComponentString("Recurrent Complex is in lightweight mode!"));
}
if (StructureRegistry.INSTANCE.ids().isEmpty()) {
commandSender.sendMessage(new TextComponentString("No registered structures!"));
sane = false;
}
if (!Files.isReadable(ResourceDirectory.getCustomDirectory().toPath())) {
commandSender.sendMessage(new TextComponentString("Can't read files from custom directory"));
sane = false;
}
for (ModContainer mod : Loader.instance().getModList()) {
String domain = mod.getModId();
Path path = null;
try {
path = RCFiles.pathFromResourceLocation(new ResourceLocation(domain.toLowerCase(), ""));
if (path != null && !Files.isReadable(path)) {
commandSender.sendMessage(new TextComponentString("Can't read files from mod: " + mod.getModId()));
sane = false;
}
} catch (RCFiles.ResourceLocationLoadException e) {
RecurrentComplex.logger.error(e);
commandSender.sendMessage(new TextComponentString("Error reading files from mod " + mod.getModId() + ": "));
commandSender.sendMessage(new TextComponentString(RCCommands.reason(e)));
sane = false;
} finally {
if (path != null)
RCFiles.closeQuietly(path.getFileSystem());
}
}
if (!Files.isReadable(ResourceDirectory.getServerDirectory().toPath())) {
commandSender.sendMessage(new TextComponentString("Can't read files from server directory"));
sane = false;
}
if (!parameters.has("short")) {
sane &= addStructureLog(commandSender, (s, structure) -> !structure.generationTypes(GenerationType.class).isEmpty(), "Missing generation type");
sane &= addGenericStructureLog(commandSender, (s, structure) -> !structure.metadata.authors.isEmpty(), "No author");
sane &= addGenericStructureLog(commandSender, (s, structure) -> structure.transformer.getTransformers().stream().allMatch(t -> t.id().length() > 0), "Transformer has empty ID");
sane &= addGenerationLog(commandSender, GenerationType.class, (structure, gen) -> gen.id().length() > 0, "Generation type has empty ID");
sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> StructureSelector.generationWeightInBiome(gen.biomeWeights, b) > 0), "Natural generation type won't accept any known biomes");
sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> StructureSelector.generationWeightInDimension(gen.dimensionWeights, d.provider) > 0), "Natural generation type won't accept any known dimensions");
sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> gen.getActiveGenerationWeight() > 0, "Natural generation type has no weight");
sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> gen.biomeExpression.test(b)), "Vanilla structure generation type won't accept any known biomes");
sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> gen.getActiveWeight() > 0, "Vanilla structure generation type has no weight");
sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> gen.minBaseLimit > 0 || gen.maxBaseLimit > 0 || gen.maxScaledLimit > 0 || gen.minScaledLimit > 0, "Vanilla structure is always limited to zero instances");
sane &= addGenerationLog(commandSender, VanillaDecorationGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> StructureSelector.generationWeightInBiome(gen.biomeWeights, b) > 0), "Vanilla structure generation type won't accept any known biomes");
sane &= addGenerationLog(commandSender, VanillaDecorationGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> StructureSelector.generationWeightInDimension(gen.dimensionWeights, d.provider) > 0), "Natural generation type won't accept any dimensions");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> gen.getWeight() > 0, "Maze generation type has no weight");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.getMazeID().trim().isEmpty(), "Maze generation type has maze id");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.mazeComponent.rooms.isEmpty(), "Maze generation type has no rooms");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.mazeComponent.exitPaths.isEmpty() || !gen.mazeComponent.defaultConnector.id.equals(ConnectorStrategy.DEFAULT_WALL), "Maze generation type has no walkable exits");
sane &= addGenerationLog(commandSender, ListGeneration.class, (structure, gen) -> !gen.listID.trim().isEmpty(), "List generation has no list id");
sane &= addGenerationLog(commandSender, ListGeneration.class, (structure, gen) -> gen.getWeight() > 0, "List generation has no weight");
sane &= addGenerationLog(commandSender, SaplingGeneration.class, (structure, gen) -> gen.getActiveWeight() > 0, "Sapling generation has no weight");
sane &= addGenerationLog(commandSender, StaticGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> gen.dimensionExpression.test(d.provider)), "Static generation won't accept any known dimensions");
}
if (sane && !parameters.has("silent"))
commandSender.sendMessage(new TextComponentString("No problems identified!"));
}
use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.
the class WorldGenStructures method planStructuresInChunk.
public static void planStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen, @Nullable Predicate<Structure> structurePredicate) {
MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = NaturalGeneration.selectors(StructureRegistry.INSTANCE).get(biomeGen, world.provider);
float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
// TODO Use STRUCTURE_TRIES
List<Pair<Structure<?>, NaturalGeneration>> generated = structureSelector.generatedStructures(random, world.getBiome(chunkPos.getBlock(0, 0, 0)), world.provider, distanceToSpawn);
generated.stream().filter(pair -> structurePredicate == null || structurePredicate.test(pair.getLeft())).forEach(pair -> planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()));
}
Aggregations