something is fishy with the getAllSchematicPlacements() methode but i want my progress saved

This commit is contained in:
rycbar0 2022-09-30 13:32:31 +02:00
parent 3a4168a661
commit 4ba3c883e6
8 changed files with 38 additions and 19 deletions

View File

@ -42,8 +42,10 @@
#try to keep usage of schematica in separate classes #try to keep usage of schematica in separate classes
-keep class baritone.utils.schematic.schematica.** -keep class baritone.utils.schematic.schematica.**
-keep class baritone.utils.schematic.litematica.**
#proguard doesnt like it when it cant find our fake schematica classes #proguard doesnt like it when it cant find our fake schematica classes
-dontwarn baritone.utils.schematic.schematica.** -dontwarn baritone.utils.schematic.schematica.**
-dontwarn baritone.utils.schematic.litematica.**
# copy all necessary libraries into tempLibraries to build # copy all necessary libraries into tempLibraries to build

View File

@ -48,8 +48,6 @@ import baritone.utils.schematic.litematica.LitematicaHelper;
import baritone.utils.schematic.schematica.SchematicaHelper; import baritone.utils.schematic.schematica.SchematicaHelper;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import fi.dy.masa.litematica.data.DataManager;
import fi.dy.masa.litematica.schematic.placement.SchematicPlacement;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@ -181,16 +179,24 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
@Override @Override
public void buildOpenLitematic() { public void buildOpenLitematic() {
if (LitematicaHelper.isLitematicaPresent()) { //TODO Investigate why true even without litematica being present logDirect("start building open litematic");
List<SchematicPlacement> placementList = DataManager.getSchematicPlacementManager().getAllSchematicPlacements(); if (LitematicaHelper.isLitematicaPresent()) {
if (placementList.size()>0) { logDirect("litematica is present"); //TODO debug line remove
String name = LitematicaHelper.getName(placementList,0); if (LitematicaHelper.hasLoadedSchematic()) {
File schemFile = LitematicaHelper.getSchematicFile(placementList,0); logDirect("a schematic is present"); //TODO debug line remove
Vec3i origin = LitematicaHelper.getOrigin(placementList,0); String name = LitematicaHelper.getName(0);
File schemFile = LitematicaHelper.getSchematicFile(0);
Vec3i origin = LitematicaHelper.getOrigin(0);
build(name, schemFile, origin); boolean success = build(name, schemFile, origin);
if (success) {
logDirect(String.format("Building Schematic: %s\nOrigion: %s",name,origin));
} else { } else {
logDirect("No schematic currently open"); logDirect("Couldn't load the schematic. That is strange.");
//this should happen as invalid schematics should not be abel to be loaded in litematica in the first place
}
} else {
logDirect("No schematic currently loaded");
} }
} else { } else {
logDirect("Litematica is not present"); logDirect("Litematica is not present");

View File

@ -18,13 +18,15 @@
package baritone.utils.schematic.litematica; package baritone.utils.schematic.litematica;
import fi.dy.masa.litematica.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.SchematicPlacement;
import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
public enum LitematicaHelper { ; public final class LitematicaHelper {
public static boolean isLitematicaPresent() { public static boolean isLitematicaPresent() {
try { try {
Class.forName(Litematica.class.getName()); Class.forName(Litematica.class.getName());
@ -33,18 +35,27 @@ public enum LitematicaHelper { ;
return false; return false;
} }
} }
public static String getName(List<SchematicPlacement> placementList, int i) { //TODO compact into one line when debugging is done
return placementList.get(i).getName(); 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;
} }
public static Vec3i getOrigin(List<SchematicPlacement> placementList, int i) { public static String getName(int i) {
return DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getName();
}
public static Vec3i getOrigin(int i) {
int x,y,z; int x,y,z;
x=placementList.get(i).getOrigin().getX(); x=DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getOrigin().getX();
y=placementList.get(i).getOrigin().getY(); y=DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getOrigin().getY();
z=placementList.get(i).getOrigin().getZ(); z=DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getOrigin().getZ();
return new Vec3i(x,y,z); return new Vec3i(x,y,z);
} }
public static File getSchematicFile(List<SchematicPlacement> placementList, int i) { public static File getSchematicFile(int i) {
return placementList.get(i).getSchematicFile(); return DataManager.getSchematicPlacementManager().getAllSchematicPlacements().get(i).getSchematicFile();
} }
} }