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 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);
}
}
use of com.ldtteam.structurize.util.TickedWorldOperation in project Structurize by ldtteam.
the class Manager method undo.
/**
* Undo a change to the world made by a player.
*
* @param player the player who made it.
* @param operationID
*/
public static void undo(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.undo.notfound"), player.getUUID());
return;
}
for (final Iterator<ChangeStorage> iterator = list.iterator(); iterator.hasNext(); ) {
final ChangeStorage storage = iterator.next();
if (storage.getID() == operationID) {
if (!storage.isDone()) {
player.sendMessage(new TranslationTextComponent("structurize.gui.undoredo.undo.inprogress", storage.getOperation()), player.getUUID());
return;
}
player.sendMessage(new TranslationTextComponent("structurize.gui.undoredo.undo.add", storage.getOperation()), player.getUUID());
addToQueue(new TickedWorldOperation(storage, player, TickedWorldOperation.OperationType.UNDO));
if (storage.getOperation().indexOf(TickedWorldOperation.OperationType.UNDO.toString()) == 0) {
iterator.remove();
}
return;
}
}
player.sendMessage(new TranslationTextComponent("structurize.gui.undoredo.undo.notfound"), player.getUUID());
}
use of com.ldtteam.structurize.util.TickedWorldOperation in project minecolonies by ldtteam.
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;
}
Aggregations