LitematicaCommand added to build loaded schematics

This commit is contained in:
schmar03 2022-09-28 14:15:48 +02:00
parent d928e705b9
commit 293f5db172
7 changed files with 147 additions and 7 deletions

View File

@ -50,7 +50,6 @@ 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.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 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;
@ -182,9 +181,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
@Override @Override
public void buildOpenLitematic() { public void buildOpenLitematic() {
if (LitematicaHelper.isLitematicaPresent()) { if (LitematicaHelper.isLitematicaPresent()) { //TODO Investigate why true even without litematica being present
SchematicPlacementManager placementManager = DataManager.getSchematicPlacementManager(); List<SchematicPlacement> placementList = DataManager.getSchematicPlacementManager().getAllSchematicPlacements();
List<SchematicPlacement> placementList = placementManager.getAllSchematicsPlacements();
if (placementList.size()>0) { if (placementList.size()>0) {
String name = LitematicaHelper.getName(placementList,0); String name = LitematicaHelper.getName(placementList,0);
File schemFile = LitematicaHelper.getSchematicFile(placementList,0); File schemFile = LitematicaHelper.getSchematicFile(placementList,0);
@ -194,6 +192,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
} else { } else {
logDirect("No schematic currently open"); logDirect("No schematic currently open");
} }
} else {
logDirect("Litematica is not present"); logDirect("Litematica is not present");
} }
} }

View File

@ -17,9 +17,8 @@
package baritone.utils.schematic.litematica; package baritone.utils.schematic.litematica;
import com.github.lunatrius.schematica.Schematica; import fi.dy.masa.litematica.Litematica;
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;
@ -28,7 +27,7 @@ import java.util.List;
public enum LitematicaHelper { ; public enum LitematicaHelper { ;
public static boolean isLitematicaPresent() { public static boolean isLitematicaPresent() {
try { try {
Class.forName(Schematica.class.getName()); Class.forName(Litematica.class.getName());
return true; return true;
} catch (ClassNotFoundException | NoClassDefFoundError ex) { } catch (ClassNotFoundException | NoClassDefFoundError ex) {
return false; return false;

View File

@ -0,0 +1,21 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package fi.dy.masa.litematica;
public class Litematica {
}

View File

@ -0,0 +1,31 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package fi.dy.masa.litematica.data;
import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager;
public class DataManager {
public static final DataManager INSTANCE = new DataManager();
private final SchematicPlacementManager schematicPlacementManager = new SchematicPlacementManager();
private static DataManager getInstance() {
return INSTANCE;
}
public static SchematicPlacementManager getSchematicPlacementManager() {
return getInstance().schematicPlacementManager;
}
}

View File

@ -0,0 +1,22 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package fi.dy.masa.litematica.schematic.placement;
public class SchematicPlacement extends SchematicPlacementUnloaded {
}

View File

@ -0,0 +1,29 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package fi.dy.masa.litematica.schematic.placement;
import java.util.ArrayList;
import java.util.List;
public class SchematicPlacementManager {
private final List<SchematicPlacement> schematicPlacements = new ArrayList<>();
public List<SchematicPlacement> getAllSchematicPlacements() {
return schematicPlacements;
}
}

View File

@ -0,0 +1,39 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package fi.dy.masa.litematica.schematic.placement;
import net.minecraft.util.math.BlockPos;
import javax.annotation.Nullable;
import java.io.File;
public class SchematicPlacementUnloaded {
protected String name = "?";
@Nullable protected File schematicFile;
protected BlockPos origin = BlockPos.ORIGIN;
public String getName() {
return this.name;
}
@Nullable
public File getSchematicFile() {
return this.schematicFile;
}
public BlockPos getOrigin() {
return this.origin;
}
}