mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Reimplement jigsaw closes #610
This commit is contained in:
parent
07b8c5087b
commit
164242ae4b
@ -50,6 +50,7 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
private CommandPregen pregen;
|
private CommandPregen pregen;
|
||||||
private CommandSettings settings;
|
private CommandSettings settings;
|
||||||
private CommandObject object;
|
private CommandObject object;
|
||||||
|
private CommandJigsaw jigsaw;
|
||||||
private CommandWhat what;
|
private CommandWhat what;
|
||||||
|
|
||||||
@Decree(description = "Create a new world", aliases = "+")
|
@Decree(description = "Create a new world", aliases = "+")
|
||||||
|
111
src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java
Normal file
111
src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package com.volmit.iris.core.commands;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
|
import com.volmit.iris.core.edit.JigsawEditor;
|
||||||
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
|
import com.volmit.iris.core.service.ObjectSVC;
|
||||||
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
|
import com.volmit.iris.core.service.WandSVC;
|
||||||
|
import com.volmit.iris.engine.jigsaw.PlannedStructure;
|
||||||
|
import com.volmit.iris.engine.object.*;
|
||||||
|
import com.volmit.iris.util.data.Cuboid;
|
||||||
|
import com.volmit.iris.util.decree.DecreeExecutor;
|
||||||
|
import com.volmit.iris.util.decree.DecreeOrigin;
|
||||||
|
import com.volmit.iris.util.decree.annotations.Decree;
|
||||||
|
import com.volmit.iris.util.decree.annotations.Param;
|
||||||
|
import com.volmit.iris.util.decree.specialhandlers.ObjectHandler;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import com.volmit.iris.util.math.Direction;
|
||||||
|
import com.volmit.iris.util.math.RNG;
|
||||||
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
|
import com.volmit.iris.util.scheduling.Queue;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.TileState;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Decree(name = "jigsaw", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris jigsaw commands")
|
||||||
|
public class CommandJigsaw implements DecreeExecutor {
|
||||||
|
@Decree(description = "Edit a jigsaw piece")
|
||||||
|
public void edit(
|
||||||
|
@Param(description = "The jigsaw piece to edit")
|
||||||
|
IrisJigsawPiece piece
|
||||||
|
) {
|
||||||
|
File dest = piece.getLoadFile();
|
||||||
|
new JigsawEditor(player(), piece, IrisData.loadAnyObject(piece.getObject()), dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Decree(description = "Place a jigsaw structure")
|
||||||
|
public void place(
|
||||||
|
@Param(description = "The jigsaw structure to place")
|
||||||
|
IrisJigsawStructure structure
|
||||||
|
) {
|
||||||
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
|
PlannedStructure ps = new PlannedStructure(structure, new IrisPosition(player().getLocation()), new RNG());
|
||||||
|
sender().sendMessage(C.GREEN + "Generated " + ps.getPieces().size() + " pieces in " + Form.duration(p.getMilliseconds(), 2));
|
||||||
|
ps.place(world());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Decree(description = "Create a jigsaw piece")
|
||||||
|
public void create(
|
||||||
|
@Param(description = "The name of the jigsaw piece")
|
||||||
|
String piece,
|
||||||
|
@Param(description = "The project to add the jigsaw piece to")
|
||||||
|
String project,
|
||||||
|
@Param(description = "The object to use for this piece", customHandler = ObjectHandler.class)
|
||||||
|
String object
|
||||||
|
) {
|
||||||
|
IrisObject o = IrisData.loadAnyObject(object);
|
||||||
|
|
||||||
|
if (object == null) {
|
||||||
|
sender().sendMessage(C.RED + "Failed to find existing object");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File dest = Iris.instance.getDataFile("packs", project, "jigsaw-pieces", piece + ".json");
|
||||||
|
new JigsawEditor(player(), null, o, dest);
|
||||||
|
sender().sendMessage(C.GRAY + "* Right Click blocks to make them connectors");
|
||||||
|
sender().sendMessage(C.GRAY + "* Right Click connectors to orient them");
|
||||||
|
sender().sendMessage(C.GRAY + "* Shift + Right Click connectors to remove them");
|
||||||
|
sender().sendMessage(C.GREEN + "Remember to use /iris jigsaw save");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Decree(description = "Exit the current jigsaw editor")
|
||||||
|
public void exit()
|
||||||
|
{
|
||||||
|
JigsawEditor editor = JigsawEditor.editors.get(player());
|
||||||
|
|
||||||
|
if (editor == null) {
|
||||||
|
sender().sendMessage(C.GOLD +"You don't have any pieces open to exit!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.exit();
|
||||||
|
sender().sendMessage(C.GREEN +"Exited Jigsaw Editor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Decree(description = "Save & Exit the current jigsaw editor")
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
JigsawEditor editor = JigsawEditor.editors.get(player());
|
||||||
|
|
||||||
|
if (editor == null) {
|
||||||
|
sender().sendMessage(C.GOLD +"You don't have any pieces open to save!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.close();
|
||||||
|
sender().sendMessage(C.GREEN +"Saved & Exited Jigsaw Editor");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user