Compare commits

...

4 Commits

Author SHA1 Message Date
Thojo0 c425bef68b
Merge b8b6caccb3 into 62b2f81ba1 2024-03-30 20:22:07 +00:00
Thojo0 b8b6caccb3 fix accidentally spaces 2023-11-05 14:54:56 +00:00
Thojo0 4ff6175227 fix builderprocess accidentally removing and changing things 2023-11-05 14:45:53 +00:00
Thojo0 b2c26b751a support for building selected litematic 2023-11-05 00:25:16 +00:00
5 changed files with 42 additions and 5 deletions

View File

@ -58,6 +58,8 @@ public interface IBuilderProcess extends IBaritoneProcess {
void buildOpenSchematic();
void buildOpenLitematic();
void buildOpenLitematic(int i);
void pause();

View File

@ -40,11 +40,13 @@ public class LitematicaCommand extends Command {
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.");
try {
baritone.getBuilderProcess().buildOpenLitematic(schematic);
} catch (IndexOutOfBoundsException e) {
logDirect("Pleas provide a valid index.");
}
} else {
baritone.getBuilderProcess().buildOpenLitematic();
}
}

View File

@ -225,6 +225,20 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
}
@Override
public void buildOpenLitematic() {
if (LitematicaHelper.isLitematicaPresent()) {
Integer selectedIndex = LitematicaHelper.getSelectedIndex();
if (selectedIndex != -1) {
buildOpenLitematic(selectedIndex);
} else {
logDirect("No schematic currently selected");
}
} else {
logDirect("Litematica is not present");
}
}
@Override
public void buildOpenLitematic(int i) {
if (LitematicaHelper.isLitematicaPresent()) {

View File

@ -54,6 +54,17 @@ public final class LitematicaHelper {
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().size() > 0;
}
/**
* @return the index of the currently selected schematic. -1 if none selected.
*/
public static Integer getSelectedIndex() {
try {
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().indexOf(DataManager.getSchematicPlacementManager().getSelectedSchematicPlacement());
} catch (NullPointerException e) {
return -1;
}
}
/**
* @param i index of the Schematic in the schematic placement list.
* @return the name of the requested schematic.

View File

@ -19,13 +19,21 @@ package fi.dy.masa.litematica.schematic.placement;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
public class SchematicPlacementManager {
private final List<SchematicPlacement> schematicPlacements = new ArrayList<>();
@Nullable
private SchematicPlacement selectedPlacement;
//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;
}
public SchematicPlacement getSelectedSchematicPlacement() {
return selectedPlacement;
}
}