Search in sources :

Example 1 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class CommandPaste method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args, "mirror", "generate", "select");
    EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(sender);
    RCEntityInfo entityInfo = RCCommands.getStructureEntityInfo(entityPlayerMP, null);
    NBTTagCompound worldData = entityInfo.getWorldDataClipboard();
    if (worldData == null)
        throw ServerTranslations.commandException("commands.strucPaste.noClipboard");
    WorldServer world = (WorldServer) sender.getEntityWorld();
    BlockPos pos = parameters.pos("x", "y", "z", sender.getPosition(), false).require();
    AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    String seed = parameters.get("seed").first().optional().orElse(null);
    boolean generate = parameters.has("generate");
    boolean select = parameters.has("select");
    GenericStructure structure = GenericStructure.createDefaultStructure();
    structure.worldDataCompound = worldData;
    // TODO Generate with generation info?
    OperationRegistry.queueOperation(new OperationGenerateStructure(structure, null, transform, pos, generate).withSeed(seed).prepare(world), sender);
    if (select) {
        StructureGenerator<?> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
        // Can never not place so don't handle
        //noinspection OptionalGetWithoutIsPresent
        StructureBoundingBox boundingBox = generator.boundingBox().get();
        SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
        owner.setSelection(RCBlockAreas.from(boundingBox));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 2 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class CommandSelectCopy method execute.

@Override
public void execute(MockWorld world, ICommandSender commandSender, String[] args) throws CommandException {
    RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(commandSender, null);
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    RCCommands.assertSize(commandSender, selectionOwner);
    BlockArea area = selectionOwner.getSelection();
    IvWorldData worldData = IvWorldData.capture(world, area, true);
    RCEntityInfo.setWorldDataClipboard(worldData.createTagCompound());
    commandSender.sendMessage(ServerTranslations.format("commands.selectCopy.success", RCTextStyle.area(area)));
}
Also used : BlockArea(ivorius.ivtoolkit.blocks.BlockArea) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo)

Example 3 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class CommandConfirm method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    EntityPlayer player = getCommandSenderAsPlayer(commandSender);
    RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
    if (!RCEntityInfo.performOperation((WorldServer) commandSender.getEntityWorld(), player))
        throw ServerTranslations.commandException("commands.rc.noOperation");
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo)

Example 4 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class OperationRegistry method queueOperation.

public static void queueOperation(Operation operation, ICommandSender commandSender) throws PlayerNotFoundException {
    boolean instant = true;
    if (commandSender instanceof EntityPlayer) {
        EntityPlayer player = CommandBase.getCommandSenderAsPlayer(commandSender);
        RCEntityInfo info = RCEntityInfo.get(player, null);
        if (info != null) {
            if (info.getPreviewType() != Operation.PreviewType.NONE) {
                info.queueOperation(operation, player);
                instant = false;
                ITextComponent confirmComponent = new TextComponentString("/" + RCCommands.confirm.getName());
                confirmComponent.getStyle().setColor(TextFormatting.GREEN);
                confirmComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.confirm.getName()));
                confirmComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcconfirm.run")));
                ITextComponent cancelComponent = new TextComponentString("/" + RCCommands.cancel.getName());
                cancelComponent.getStyle().setColor(TextFormatting.RED);
                cancelComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.cancel.getName()));
                cancelComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rccancel.run")));
                commandSender.sendMessage(ServerTranslations.format("commands.rc.queuedOp", confirmComponent, cancelComponent));
            }
        }
    }
    if (instant)
        operation.perform((WorldServer) commandSender.getEntityWorld());
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 5 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class CommandVisual method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    if (args.length < 2)
        throw ServerTranslations.wrongUsageException("commands.rcvisual.usage");
    boolean enabled = parseBoolean(args[1]);
    EntityPlayer player = getCommandSenderAsPlayer(commandSender);
    RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
    switch(args[0]) {
        case "rulers":
            RCEntityInfo.showGrid = enabled;
            RCEntityInfo.sendOptionsToClients(player);
            break;
        default:
            throw ServerTranslations.wrongUsageException("commands.rcvisual.usage");
    }
    if (enabled)
        commandSender.sendMessage(ServerTranslations.format("commands.rcvisual.enabled", args[0]));
    else
        commandSender.sendMessage(ServerTranslations.format("commands.rcvisual.disabled", args[0]));
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo)

Aggregations

RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)3 WorldServer (net.minecraft.world.WorldServer)3 CapabilitySelection (ivorius.reccomplex.capability.CapabilitySelection)2 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)2 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 BlockPos (net.minecraft.util.math.BlockPos)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)1 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)1 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)1 RCConfig (ivorius.reccomplex.RCConfig)1 MaterialNegativeSpace (ivorius.reccomplex.block.materials.MaterialNegativeSpace)1 RCCommands (ivorius.reccomplex.commands.RCCommands)1 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)1 SimpleLeveledRegistry (ivorius.reccomplex.files.SimpleLeveledRegistry)1 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)1 GuiEditGenericStructure (ivorius.reccomplex.gui.editstructure.GuiEditGenericStructure)1