Search in sources :

Example 1 with BlockExpression

use of ivorius.reccomplex.utils.expression.BlockExpression in project RecurrentComplex by Ivorforce.

the class CommandContaining method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    BlockExpression matcher = parameters.rc().expression(new BlockExpression(RecurrentComplex.specialRegistry)).require();
    CommandSearchStructure.postResultMessage(commandSender, RCTextStyle::structure, CommandSearchStructure.search(StructureRegistry.INSTANCE.ids(), name -> containedBlocks(StructureRegistry.INSTANCE.get(name), matcher)));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) IvBlockCollection(ivorius.ivtoolkit.blocks.IvBlockCollection) BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) RCConfig(ivorius.reccomplex.RCConfig) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) List(java.util.List) ICommandSender(net.minecraft.command.ICommandSender) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Nullable(javax.annotation.Nullable) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression)

Example 2 with BlockExpression

use of ivorius.reccomplex.utils.expression.BlockExpression in project RecurrentComplex by Ivorforce.

the class CommandSearchStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    List<ToDoubleFunction<String>> ranks = new ArrayList<>();
    consider(ranks, parameters.get(0), Parameter::varargsList, (s, t) -> StructureSearch.searchRank(t, StructureSearch.keywords(StructureRegistry.INSTANCE.id(s), s)));
    consider(ranks, parameters.get("containing"), e -> RCP.expression(e, new BlockExpression(RecurrentComplex.specialRegistry)), StructureSearch::containedBlocks);
    consider(ranks, parameters.get("biome"), MCP::biome, StructureSearch::biome);
    consider(ranks, parameters.get("dimension"), MCP.dimension(server, sender), StructureSearch::dimension);
    consider(ranks, parameters.get("maze"), p -> p, StructureSearch::maze);
    consider(ranks, parameters.get("list"), p -> p, StructureSearch::list);
    consider(ranks, parameters.get("author"), p -> p, StructureSearch::author);
    boolean all = parameters.has("all");
    if (ranks.stream().noneMatch(Objects::nonNull))
        throw new WrongUsageException(getUsage(sender));
    postResultMessage("Results: ", sender, RCTextStyle::structure, search(all ? StructureRegistry.INSTANCE.ids() : StructureRegistry.INSTANCE.activeIDs(), name -> ranks.stream().filter(Objects::nonNull).mapToDouble(f -> f.applyAsDouble(name)).reduce(1, (a, b) -> a * b)));
}
Also used : BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression) java.util(java.util) MCE(ivorius.mcopts.commands.parameters.expect.MCE) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) TextComponentBase(net.minecraft.util.text.TextComponentBase) RCConfig(ivorius.reccomplex.RCConfig) Function(java.util.function.Function) ServerTranslations(ivorius.mcopts.translation.ServerTranslations) ITextComponent(net.minecraft.util.text.ITextComponent) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) Nonnull(javax.annotation.Nonnull) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) CommandExpecting(ivorius.mcopts.commands.CommandExpecting) Collectors(java.util.stream.Collectors) MCP(ivorius.mcopts.commands.parameters.MCP) TextComponentString(net.minecraft.util.text.TextComponentString) ToDoubleBiFunction(java.util.function.ToDoubleBiFunction) RCP(ivorius.reccomplex.commands.parameters.RCP) Expect(ivorius.mcopts.commands.parameters.expect.Expect) ICommandSender(net.minecraft.command.ICommandSender) WrongUsageException(net.minecraft.command.WrongUsageException) ToDoubleFunction(java.util.function.ToDoubleFunction) Doubles(com.google.common.primitives.Doubles) Parameter(ivorius.mcopts.commands.parameters.Parameter) Parameters(ivorius.mcopts.commands.parameters.Parameters) Parameters(ivorius.mcopts.commands.parameters.Parameters) BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression) WrongUsageException(net.minecraft.command.WrongUsageException) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) Parameter(ivorius.mcopts.commands.parameters.Parameter) MCP(ivorius.mcopts.commands.parameters.MCP) ToDoubleFunction(java.util.function.ToDoubleFunction)

Aggregations

RCConfig (ivorius.reccomplex.RCConfig)2 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)2 RCTextStyle (ivorius.reccomplex.commands.RCTextStyle)2 BlockExpression (ivorius.reccomplex.utils.expression.BlockExpression)2 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)2 StructureRegistry (ivorius.reccomplex.world.gen.feature.structure.StructureRegistry)2 CommandException (net.minecraft.command.CommandException)2 ICommandSender (net.minecraft.command.ICommandSender)2 MinecraftServer (net.minecraft.server.MinecraftServer)2 Doubles (com.google.common.primitives.Doubles)1 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)1 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)1 MCP (ivorius.mcopts.commands.parameters.MCP)1 Parameter (ivorius.mcopts.commands.parameters.Parameter)1 Parameters (ivorius.mcopts.commands.parameters.Parameters)1 Expect (ivorius.mcopts.commands.parameters.expect.Expect)1 MCE (ivorius.mcopts.commands.parameters.expect.MCE)1 ServerTranslations (ivorius.mcopts.translation.ServerTranslations)1 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)1 RCP (ivorius.reccomplex.commands.parameters.RCP)1