Search in sources :

Example 1 with CreativeStructureHandler

use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.

the class WindowBuildTool method commonStructureUpdate.

/**
 * Changes the current structure.
 */
public static void commonStructureUpdate() {
    final String sname = Settings.instance.getStructureName();
    if (sname == null) {
        return;
    }
    final StructureName structureName = new StructureName(sname);
    final String md5 = Structures.getMD5(structureName.toString());
    final IStructureHandler structure = new CreativeStructureHandler(Minecraft.getInstance().level, new BlockPos(0, 0, 0), structureName.toString(), new PlacementSettings(Settings.instance.getMirror(), BlockUtils.getRotation(Settings.instance.getRotation())), true);
    if (!structure.hasBluePrint() || !structure.isCorrectMD5(md5)) {
        if (!structure.hasBluePrint()) {
            Log.getLogger().info("Blueprint structure " + structureName + " missing");
        } else {
            Log.getLogger().info("structure " + structureName + " md5 error");
        }
        Log.getLogger().info("Request To Server for structure " + structureName);
        if (ServerLifecycleHooks.getCurrentServer() == null) {
            Network.getNetwork().sendToServer(new SchematicRequestMessage(structureName.toString()));
            return;
        } else {
            Log.getLogger().error("WindowBuildTool: Need to download schematic on a standalone client/server. This should never happen");
        }
    }
    Settings.instance.setStructureName(structureName.toString());
    Settings.instance.setActiveSchematic(structure.getBluePrint());
}
Also used : CreativeStructureHandler(com.ldtteam.structurize.placement.structure.CreativeStructureHandler) SchematicRequestMessage(com.ldtteam.structurize.network.messages.SchematicRequestMessage) IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) StructureName(com.ldtteam.structurize.management.StructureName) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Example 2 with CreativeStructureHandler

use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.

the class StructurePlacementUtils method loadAndPlaceStructureWithRotation.

/**
 * Load a structure into this world
 * and place it in the right position and rotation.
 *
 * @param worldObj the world to load it in
 * @param name     the structures name
 * @param pos      coordinates
 * @param rotation the rotation.
 * @param mirror   the mirror used.
 * @param fancyPlacement if fancy or complete.
 * @param player   the placing player.
 */
public static void loadAndPlaceStructureWithRotation(final World worldObj, @NotNull final String name, @NotNull final BlockPos pos, final Rotation rotation, @NotNull final Mirror mirror, final boolean fancyPlacement, final ServerPlayerEntity player) {
    try {
        @NotNull final IStructureHandler structure = new CreativeStructureHandler(worldObj, pos, name, new PlacementSettings(mirror, rotation), fancyPlacement);
        structure.getBluePrint().rotateWithMirror(rotation, mirror, worldObj);
        @NotNull final StructurePlacer instantPlacer = new StructurePlacer(structure);
        Manager.addToQueue(new TickedWorldOperation(instantPlacer, player));
    } catch (final IllegalStateException e) {
        Log.getLogger().warn("Could not load structure!", e);
    }
}
Also used : CreativeStructureHandler(com.ldtteam.structurize.placement.structure.CreativeStructureHandler) IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) NotNull(org.jetbrains.annotations.NotNull) TickedWorldOperation(com.ldtteam.structurize.util.TickedWorldOperation)

Example 3 with CreativeStructureHandler

use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.

the class StructurePlacementUtils method unloadStructure.

/**
 * Unload a structure at a certain location.
 *
 * @param world    the world.
 * @param startPos      the position.
 * @param name    the name.
 * @param rotation the rotation.
 * @param mirror   the mirror.
 */
public static void unloadStructure(@NotNull final World world, @NotNull final BlockPos startPos, @NotNull final String name, final Rotation rotation, @NotNull final Mirror mirror) {
    @NotNull final IStructureHandler structure = new CreativeStructureHandler(world, startPos, name, new PlacementSettings(mirror, rotation), false);
    structure.getBluePrint().rotateWithMirror(rotation, mirror, world);
    @NotNull final StructurePlacer placer = new StructurePlacer(structure);
    placer.executeStructureStep(world, null, new BlockPos(0, 0, 0), StructurePlacer.Operation.BLOCK_REMOVAL, () -> placer.getIterator().increment((info, pos, handler) -> handler.getWorld().getBlockState(pos).getBlock() instanceof AirBlock), true);
}
Also used : TickedWorldOperation(com.ldtteam.structurize.util.TickedWorldOperation) World(net.minecraft.world.World) AirBlock(net.minecraft.block.AirBlock) BlockPos(net.minecraft.util.math.BlockPos) Mirror(net.minecraft.util.Mirror) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) Blueprint(com.ldtteam.structures.blueprints.v1.Blueprint) Manager(com.ldtteam.structurize.management.Manager) CreativeStructureHandler(com.ldtteam.structurize.placement.structure.CreativeStructureHandler) Rotation(net.minecraft.util.Rotation) Log(com.ldtteam.structurize.api.util.Log) IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) NotNull(org.jetbrains.annotations.NotNull) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) CreativeStructureHandler(com.ldtteam.structurize.placement.structure.CreativeStructureHandler) AirBlock(net.minecraft.block.AirBlock) IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with CreativeStructureHandler

use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.

the class StructurePlacementUtils method loadAndPlaceStructureWithRotation.

/**
 * Load a structure into this world
 * and place it in the right position and rotation.
 *
 * @param worldObj the world to load it in
 * @param blueprint the structures blueprint
 * @param pos      coordinates
 * @param rotation the rotation.
 * @param mirror   the mirror used.
 * @param fancyPlacement if fancy or complete.
 * @param player   the placing player.
 */
public static void loadAndPlaceStructureWithRotation(final World worldObj, @NotNull final Blueprint blueprint, @NotNull final BlockPos pos, final Rotation rotation, @NotNull final Mirror mirror, final boolean fancyPlacement, final ServerPlayerEntity player) {
    try {
        @NotNull final IStructureHandler structure = new CreativeStructureHandler(worldObj, pos, blueprint, new PlacementSettings(mirror, rotation), fancyPlacement);
        if (fancyPlacement) {
            structure.fancyPlacement();
        }
        structure.getBluePrint().rotateWithMirror(rotation, mirror, worldObj);
        @NotNull final StructurePlacer instantPlacer = new StructurePlacer(structure);
        Manager.addToQueue(new TickedWorldOperation(instantPlacer, player));
    } catch (final IllegalStateException e) {
        Log.getLogger().warn("Could not load structure!", e);
    }
}
Also used : CreativeStructureHandler(com.ldtteam.structurize.placement.structure.CreativeStructureHandler) IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) NotNull(org.jetbrains.annotations.NotNull) TickedWorldOperation(com.ldtteam.structurize.util.TickedWorldOperation)

Aggregations

CreativeStructureHandler (com.ldtteam.structurize.placement.structure.CreativeStructureHandler)4 IStructureHandler (com.ldtteam.structurize.placement.structure.IStructureHandler)4 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)4 TickedWorldOperation (com.ldtteam.structurize.util.TickedWorldOperation)3 NotNull (org.jetbrains.annotations.NotNull)3 BlockPos (net.minecraft.util.math.BlockPos)2 Blueprint (com.ldtteam.structures.blueprints.v1.Blueprint)1 Log (com.ldtteam.structurize.api.util.Log)1 Manager (com.ldtteam.structurize.management.Manager)1 StructureName (com.ldtteam.structurize.management.StructureName)1 SchematicRequestMessage (com.ldtteam.structurize.network.messages.SchematicRequestMessage)1 AirBlock (net.minecraft.block.AirBlock)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 Mirror (net.minecraft.util.Mirror)1 Rotation (net.minecraft.util.Rotation)1 World (net.minecraft.world.World)1