litematica command works and added schematic selection if more than 1 schematic is loaded
bug: if schematic origin isnt minimum corner schematic is built in the wrong place
This commit is contained in:
parent
4ba3c883e6
commit
025f6235f9
@ -58,7 +58,7 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void buildOpenLitematic();
|
||||
void buildOpenLitematic(int i);
|
||||
|
||||
void pause();
|
||||
|
||||
|
@ -34,8 +34,18 @@ public class LitematicaCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
baritone.getBuilderProcess().buildOpenLitematic();
|
||||
int schematic = 0;
|
||||
if(args.hasAny()) {
|
||||
args.requireMax(1);
|
||||
if (args.is(Integer.class)) {
|
||||
schematic = args.getAs(Integer.class)-1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
baritone.getBuilderProcess().buildOpenLitematic(schematic);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logDirect("Pleas provide a valid index.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,10 +61,11 @@ public class LitematicaCommand extends Command {
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"Builds the schematic currently open in Litematica.",
|
||||
"Build a schematic currently open in Litematica.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> litematica"
|
||||
"> litematica",
|
||||
"> litematica <#>"
|
||||
);
|
||||
}
|
||||
}
|
@ -178,15 +178,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpenLitematic() {
|
||||
logDirect("start building open litematic");
|
||||
public void buildOpenLitematic(int i) {
|
||||
if (LitematicaHelper.isLitematicaPresent()) {
|
||||
logDirect("litematica is present"); //TODO debug line remove
|
||||
if (LitematicaHelper.hasLoadedSchematic()) {
|
||||
logDirect("a schematic is present"); //TODO debug line remove
|
||||
String name = LitematicaHelper.getName(0);
|
||||
File schemFile = LitematicaHelper.getSchematicFile(0);
|
||||
Vec3i origin = LitematicaHelper.getOrigin(0);
|
||||
String name = LitematicaHelper.getName(i);
|
||||
File schemFile = LitematicaHelper.getSchematicFile(i);
|
||||
Vec3i origin = LitematicaHelper.getOrigin(i);
|
||||
|
||||
boolean success = build(name, schemFile, origin);
|
||||
if (success) {
|
||||
|
@ -19,12 +19,9 @@ package baritone.utils.schematic.litematica;
|
||||
|
||||
import fi.dy.masa.litematica.Litematica;
|
||||
import fi.dy.masa.litematica.data.DataManager;
|
||||
import fi.dy.masa.litematica.schematic.placement.SchematicPlacement;
|
||||
import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public final class LitematicaHelper {
|
||||
public static boolean isLitematicaPresent() {
|
||||
@ -35,27 +32,21 @@ public final class LitematicaHelper {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//TODO compact into one line when debugging is done
|
||||
public static boolean hasLoadedSchematic() {
|
||||
System.out.println("start checking for schematic"); //TODO debug line remove
|
||||
SchematicPlacementManager a = DataManager.getSchematicPlacementManager();
|
||||
System.out.println("manager aquired"); //TODO debug line remove
|
||||
List< SchematicPlacement> b = a.getAllSchematicPlacements();
|
||||
System.out.println("list aquired"); //TODO debug line remove
|
||||
return b.size()>0;
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().size()>0;
|
||||
}
|
||||
public static String getName(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getName();
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getName();
|
||||
}
|
||||
public static Vec3i getOrigin(int i) {
|
||||
int x,y,z;
|
||||
x=DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getOrigin().getX();
|
||||
y=DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getOrigin().getY();
|
||||
z=DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getOrigin().getZ();
|
||||
x=DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin().getX();
|
||||
y=DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin().getY();
|
||||
z=DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin().getZ();
|
||||
return new Vec3i(x,y,z);
|
||||
}
|
||||
public static File getSchematicFile(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getSchematicFile();
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getSchematicFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,9 @@ import java.util.List;
|
||||
public class SchematicPlacementManager {
|
||||
private final List<SchematicPlacement> schematicPlacements = new ArrayList<>();
|
||||
|
||||
public List<SchematicPlacement> getAllSchematicPlacements() {
|
||||
//in case of a java.lang.NoSuchMethodError try change the name of this method to getAllSchematicPlacements()
|
||||
// there are inconsistencies in the litematica mod about the naming of this method
|
||||
public List<SchematicPlacement> getAllSchematicsPlacements() {
|
||||
return schematicPlacements;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user