use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.
the class CommandPaste method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args, "mirror", "generate", "select");
EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(sender);
RCEntityInfo entityInfo = RCCommands.getStructureEntityInfo(entityPlayerMP, null);
NBTTagCompound worldData = entityInfo.getWorldDataClipboard();
if (worldData == null)
throw ServerTranslations.commandException("commands.strucPaste.noClipboard");
WorldServer world = (WorldServer) sender.getEntityWorld();
BlockPos pos = parameters.pos("x", "y", "z", sender.getPosition(), false).require();
AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
String seed = parameters.get("seed").first().optional().orElse(null);
boolean generate = parameters.has("generate");
boolean select = parameters.has("select");
GenericStructure structure = GenericStructure.createDefaultStructure();
structure.worldDataCompound = worldData;
// TODO Generate with generation info?
OperationRegistry.queueOperation(new OperationGenerateStructure(structure, null, transform, pos, generate).withSeed(seed).prepare(world), sender);
if (select) {
StructureGenerator<?> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
// Can never not place so don't handle
//noinspection OptionalGetWithoutIsPresent
StructureBoundingBox boundingBox = generator.boundingBox().get();
SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
owner.setSelection(RCBlockAreas.from(boundingBox));
}
}
use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.
the class CommandSelectCopy method execute.
@Override
public void execute(MockWorld world, ICommandSender commandSender, String[] args) throws CommandException {
RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(commandSender, null);
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
RCCommands.assertSize(commandSender, selectionOwner);
BlockArea area = selectionOwner.getSelection();
IvWorldData worldData = IvWorldData.capture(world, area, true);
RCEntityInfo.setWorldDataClipboard(worldData.createTagCompound());
commandSender.sendMessage(ServerTranslations.format("commands.selectCopy.success", RCTextStyle.area(area)));
}
use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.
the class CommandConfirm method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
EntityPlayer player = getCommandSenderAsPlayer(commandSender);
RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
if (!RCEntityInfo.performOperation((WorldServer) commandSender.getEntityWorld(), player))
throw ServerTranslations.commandException("commands.rc.noOperation");
}
use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.
the class OperationRegistry method queueOperation.
public static void queueOperation(Operation operation, ICommandSender commandSender) throws PlayerNotFoundException {
boolean instant = true;
if (commandSender instanceof EntityPlayer) {
EntityPlayer player = CommandBase.getCommandSenderAsPlayer(commandSender);
RCEntityInfo info = RCEntityInfo.get(player, null);
if (info != null) {
if (info.getPreviewType() != Operation.PreviewType.NONE) {
info.queueOperation(operation, player);
instant = false;
ITextComponent confirmComponent = new TextComponentString("/" + RCCommands.confirm.getName());
confirmComponent.getStyle().setColor(TextFormatting.GREEN);
confirmComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.confirm.getName()));
confirmComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcconfirm.run")));
ITextComponent cancelComponent = new TextComponentString("/" + RCCommands.cancel.getName());
cancelComponent.getStyle().setColor(TextFormatting.RED);
cancelComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.cancel.getName()));
cancelComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rccancel.run")));
commandSender.sendMessage(ServerTranslations.format("commands.rc.queuedOp", confirmComponent, cancelComponent));
}
}
}
if (instant)
operation.perform((WorldServer) commandSender.getEntityWorld());
}
use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.
the class CommandVisual method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
if (args.length < 2)
throw ServerTranslations.wrongUsageException("commands.rcvisual.usage");
boolean enabled = parseBoolean(args[1]);
EntityPlayer player = getCommandSenderAsPlayer(commandSender);
RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
switch(args[0]) {
case "rulers":
RCEntityInfo.showGrid = enabled;
RCEntityInfo.sendOptionsToClients(player);
break;
default:
throw ServerTranslations.wrongUsageException("commands.rcvisual.usage");
}
if (enabled)
commandSender.sendMessage(ServerTranslations.format("commands.rcvisual.enabled", args[0]));
else
commandSender.sendMessage(ServerTranslations.format("commands.rcvisual.disabled", args[0]));
}
Aggregations