Search in sources :

Example 1 with TickedWorldOperation

use of com.ldtteam.structurize.util.TickedWorldOperation in project minecolonies by Minecolonies.

the class CreativeRaiderStructureHandler 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 colonyId       the colony id.
 * @param event          the raid event.
 * @param player         the placing player.
 * @return the placed blueprint.
 */
public static Blueprint loadAndPlaceStructureWithRotation(final World worldObj, @NotNull final String name, @NotNull final BlockPos pos, final Rotation rotation, @NotNull final Mirror mirror, final boolean fancyPlacement, final int colonyId, final IColonyRaidEvent event, @Nullable final ServerPlayerEntity player) {
    try {
        @NotNull final IStructureHandler structure = new CreativeRaiderStructureHandler(worldObj, pos, name, new PlacementSettings(mirror, rotation), fancyPlacement, event, colonyId);
        if (structure.hasBluePrint()) {
            @NotNull final StructurePlacer instantPlacer = new StructurePlacer(structure);
            Manager.addToQueue(new TickedWorldOperation(instantPlacer, player));
        }
        return structure.getBluePrint();
    } catch (final IllegalStateException e) {
        Log.getLogger().warn("Could not load structure!", e);
    }
    return null;
}
Also used : IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) NotNull(org.jetbrains.annotations.NotNull) TickedWorldOperation(com.ldtteam.structurize.util.TickedWorldOperation)

Example 2 with TickedWorldOperation

use of com.ldtteam.structurize.util.TickedWorldOperation 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 TickedWorldOperation

use of com.ldtteam.structurize.util.TickedWorldOperation in project Structurize by ldtteam.

the class Manager method redo.

/**
 * Undo a change to the world made by a player.
 *
 * @param player      the player who made it.
 * @param operationID
 */
public static void redo(final PlayerEntity player, final int operationID) {
    final List<ChangeStorage> list = changeQueue.get(player.getUUID());
    if (list == null || list.isEmpty()) {
        player.sendMessage(new TranslationTextComponent("structurize.gui.undoredo.redo.notfound"), player.getUUID());
        return;
    }
    for (final ChangeStorage storage : list) {
        if (storage.getID() == operationID) {
            if (!storage.isDone()) {
                player.sendMessage(new TranslationTextComponent("structurize.gui.undoredo.redo.inprogress", storage.getOperation()), player.getUUID());
                return;
            }
            player.sendMessage(new TranslationTextComponent("structurize.gui.undoredo.redo.add", storage.getOperation()), player.getUUID());
            addToQueue(new TickedWorldOperation(storage, player, TickedWorldOperation.OperationType.REDO));
            return;
        }
    }
    player.sendMessage(new TranslationTextComponent("structurize.gui.undoredo.redo.notfound"), player.getUUID());
}
Also used : TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) TickedWorldOperation(com.ldtteam.structurize.util.TickedWorldOperation) ChangeStorage(com.ldtteam.structurize.util.ChangeStorage)

Example 4 with TickedWorldOperation

use of com.ldtteam.structurize.util.TickedWorldOperation in project minecolonies by ldtteam.

the class CreativeRaiderStructureHandler 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 colonyId       the colony id.
 * @param event          the raid event.
 * @param player         the placing player.
 * @return the placed blueprint.
 */
public static Blueprint loadAndPlaceStructureWithRotation(final World worldObj, @NotNull final String name, @NotNull final BlockPos pos, final Rotation rotation, @NotNull final Mirror mirror, final boolean fancyPlacement, final int colonyId, final IColonyRaidEvent event, @Nullable final ServerPlayerEntity player) {
    try {
        @NotNull final IStructureHandler structure = new CreativeRaiderStructureHandler(worldObj, pos, name, new PlacementSettings(mirror, rotation), fancyPlacement, event, colonyId);
        if (structure.hasBluePrint()) {
            @NotNull final StructurePlacer instantPlacer = new StructurePlacer(structure);
            Manager.addToQueue(new TickedWorldOperation(instantPlacer, player));
        }
        return structure.getBluePrint();
    } catch (final IllegalStateException e) {
        Log.getLogger().warn("Could not load structure!", e);
    }
    return null;
}
Also used : IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) NotNull(org.jetbrains.annotations.NotNull) TickedWorldOperation(com.ldtteam.structurize.util.TickedWorldOperation)

Example 5 with TickedWorldOperation

use of com.ldtteam.structurize.util.TickedWorldOperation in project minecolonies by Minecolonies.

the class CreativeBuildingStructureHandler 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.
 * @return the placed blueprint.
 */
public static Blueprint loadAndPlaceStructureWithRotation(final World worldObj, @NotNull final String name, @NotNull final BlockPos pos, final Rotation rotation, @NotNull final Mirror mirror, final boolean fancyPlacement, @Nullable final ServerPlayerEntity player) {
    try {
        @NotNull final IStructureHandler structure = new CreativeBuildingStructureHandler(worldObj, pos, name, new PlacementSettings(mirror, rotation), fancyPlacement);
        if (structure.hasBluePrint()) {
            structure.getBluePrint().rotateWithMirror(rotation, mirror, worldObj);
            @NotNull final StructurePlacer instantPlacer = new StructurePlacer(structure);
            Manager.addToQueue(new TickedWorldOperation(instantPlacer, player));
        }
        return structure.getBluePrint();
    } catch (final IllegalStateException e) {
        Log.getLogger().warn("Could not load structure!", e);
    }
    return null;
}
Also used : IStructureHandler(com.ldtteam.structurize.placement.structure.IStructureHandler) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) NotNull(org.jetbrains.annotations.NotNull) TickedWorldOperation(com.ldtteam.structurize.util.TickedWorldOperation)

Aggregations

TickedWorldOperation (com.ldtteam.structurize.util.TickedWorldOperation)8 IStructureHandler (com.ldtteam.structurize.placement.structure.IStructureHandler)6 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)6 NotNull (org.jetbrains.annotations.NotNull)6 StructurePlacer (com.ldtteam.structurize.placement.StructurePlacer)4 CreativeStructureHandler (com.ldtteam.structurize.placement.structure.CreativeStructureHandler)2 ChangeStorage (com.ldtteam.structurize.util.ChangeStorage)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2