Search in sources :

Example 6 with BlockArea

use of ivorius.ivtoolkit.blocks.BlockArea in project RecurrentComplex by Ivorforce.

the class CommandSelectMove method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args, "mirror", "noselect");
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    RCCommands.assertSize(commandSender, selectionOwner);
    BlockPos pos = parameters.pos("x", "y", "z", selectionOwner.getSelectedPoint1(), false).require();
    AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    boolean noselect = parameters.has("noselect");
    BlockArea area = selectionOwner.getSelection();
    IvWorldData worldData = IvWorldData.capture(commandSender.getEntityWorld(), area, true);
    NBTTagCompound worldDataCompound = worldData.createTagCompound();
    GenericStructure structure = GenericStructure.createDefaultStructure();
    structure.worldDataCompound = worldDataCompound;
    OperationRegistry.queueOperation(new OperationMulti(new OperationClearArea(area), new OperationGenerateStructure(structure, null, transform, pos, true).prepare((WorldServer) commandSender.getEntityWorld())), commandSender);
    if (!noselect) {
        StructureGenerator<GenericStructure.InstanceData> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
        //noinspection OptionalGetWithoutIsPresent
        StructureBoundingBox boundingBox = generator.boundingBox().get();
        selectionOwner.setSelection(RCBlockAreas.from(boundingBox));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) OperationClearArea(ivorius.reccomplex.world.gen.feature.structure.OperationClearArea) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockArea(ivorius.ivtoolkit.blocks.BlockArea) OperationMulti(ivorius.reccomplex.world.gen.feature.structure.OperationMulti) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 7 with BlockArea

use of ivorius.ivtoolkit.blocks.BlockArea in project RecurrentComplex by Ivorforce.

the class CommandNaturalSpace method execute.

@Override
public void execute(MockWorld world, ICommandSender commandSender, String[] args) throws CommandException {
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    RCCommands.assertSize(commandSender, selectionOwner);
    BlockArea area = selectionOwner.getSelection();
    RCParameters parameters = RCParameters.of(args);
    int floorDistance = parameters.get("distance-to-floor").intAt(0).optional().orElse(0) + 1;
    int maxClosedSides = parameters.get("max-closed-sides").intAt(1).optional().orElse(3);
    placeNaturalAir(world, area, floorDistance, maxClosedSides);
}
Also used : BlockArea(ivorius.ivtoolkit.blocks.BlockArea) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner)

Example 8 with BlockArea

use of ivorius.ivtoolkit.blocks.BlockArea in project RecurrentComplex by Ivorforce.

the class CommandNaturalFloor method execute.

@Override
public void execute(MockWorld world, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    BlockArea area = RCCommands.getSelectionOwner(commandSender, null, true).getSelection();
    double expandFloor = parameters.get("expansion").doubleAt(0).optional().orElse(1.);
    placeNaturalFloor(world, area, expandFloor);
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockArea(ivorius.ivtoolkit.blocks.BlockArea)

Example 9 with BlockArea

use of ivorius.ivtoolkit.blocks.BlockArea in project RecurrentComplex by Ivorforce.

the class SelectionRenderer method renderSelection.

public static void renderSelection(EntityLivingBase entity, int ticks, float partialTicks) {
    Minecraft mc = Minecraft.getMinecraft();
    BlockPos selPoint1 = null;
    BlockPos selPoint2 = null;
    SelectionOwner owner = SelectionOwner.getOwner(entity, null);
    if (owner != null) {
        selPoint1 = owner.getSelectedPoint1();
        selPoint2 = owner.getSelectedPoint2();
    }
    GL11.glLineWidth(3.0f);
    if (selPoint1 != null) {
        GlStateManager.color(0.6f, 0.8f, 0.95f);
        AreaRenderer.renderAreaLined(new BlockArea(selPoint1, selPoint1), 0.03f);
    }
    if (selPoint2 != null) {
        GlStateManager.color(0.2f, 0.45f, 0.65f);
        AreaRenderer.renderAreaLined(new BlockArea(selPoint2, selPoint2), 0.04f);
    }
    for (EnumHand enumHand : EnumHand.values()) {
        ItemStack heldItem = entity.getHeldItem(enumHand);
        if (heldItem != null && heldItem.getItem() instanceof ItemBlockSelectorFloating) {
            float selectionRange = ((ItemBlockSelectorFloating) heldItem.getItem()).getSelectionRange(heldItem);
            BlockPos hoverPoint = ItemBlockSelectorFloating.getHoveredBlock(entity, selectionRange);
            GlStateManager.color(0.6f, 0.6f, 1.0f);
            AreaRenderer.renderAreaLined(new BlockArea(hoverPoint, hoverPoint), 0.05f);
        }
    }
    if (selPoint1 != null && selPoint2 != null) {
        BlockArea selArea = new BlockArea(selPoint1, selPoint2);
        GlStateManager.color(0.4f, 0.65f, 0.8f);
        AreaRenderer.renderAreaLined(selArea, 0.02f);
        GlStateManager.enableBlend();
        OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0001f);
        ResourceLocation curTex = TEXTURE[MathHelper.floor((ticks + partialTicks) * 0.75f) % TEXTURE.length];
        mc.renderEngine.bindTexture(curTex);
        GlStateManager.color(0.2f, 0.5f, 0.6f, 0.5f);
        AreaRenderer.renderArea(selArea, false, true, 0.01f);
        GlStateManager.color(0.4f, 0.65f, 0.8f, 0.75f);
        AreaRenderer.renderArea(selArea, false, false, 0.01f);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.002f);
        GlStateManager.disableBlend();
    }
}
Also used : BlockArea(ivorius.ivtoolkit.blocks.BlockArea) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) ItemBlockSelectorFloating(ivorius.reccomplex.item.ItemBlockSelectorFloating) EnumHand(net.minecraft.util.EnumHand) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Example 10 with BlockArea

use of ivorius.ivtoolkit.blocks.BlockArea in project RecurrentComplex by Ivorforce.

the class CommandExportSchematic method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    BlockArea area = selectionOwner.getSelection();
    RCCommands.assertSize(commandSender, selectionOwner);
    String structureName = parameters.get().first().optional().orElse("NewStructure_" + commandSender.getEntityWorld().rand.nextInt(1000));
    BlockPos lowerCoord = area.getLowerCorner();
    BlockPos higherCoord = area.getHigherCorner();
    IvWorldData data = IvWorldData.capture(commandSender.getEntityWorld(), new BlockArea(lowerCoord, higherCoord), true);
    SchematicFile schematicFile = toSchematic(data);
    SchematicLoader.writeSchematicByName(schematicFile, structureName);
    commandSender.sendMessage(ServerTranslations.format("commands.strucExportSchematic.success", structureName));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockArea(ivorius.ivtoolkit.blocks.BlockArea) SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockArea (ivorius.ivtoolkit.blocks.BlockArea)12 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)8 BlockPos (net.minecraft.util.math.BlockPos)8 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)7 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)5 Nullable (javax.annotation.Nullable)3 IBlockState (net.minecraft.block.state.IBlockState)3 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)2 OperationGenerateStructure (ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure)2 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)2 Collectors (java.util.stream.Collectors)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 WorldServer (net.minecraft.world.WorldServer)2 com.google.gson (com.google.gson)1 BlockAreas (ivorius.ivtoolkit.blocks.BlockAreas)1 BlockStates (ivorius.ivtoolkit.blocks.BlockStates)1 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)1 IvShapeHelper (ivorius.ivtoolkit.math.IvShapeHelper)1 MCRegistry (ivorius.ivtoolkit.tools.MCRegistry)1