build the schematic schematica has open
This commit is contained in:
parent
4d127acb9a
commit
d505ec4f9f
@ -55,6 +55,14 @@ sourceSets {
|
||||
launch {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
|
||||
schematica_api {
|
||||
compileClasspath += main.compileClasspath
|
||||
}
|
||||
|
||||
main {
|
||||
compileClasspath += schematica_api.output
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
|
5
scripts/proguard.pro
vendored
5
scripts/proguard.pro
vendored
@ -31,6 +31,11 @@
|
||||
# need to keep mixin names
|
||||
-keep class baritone.launch.** { *; }
|
||||
|
||||
#try to keep usage of schematica in separate classes
|
||||
-keep class baritone.utils.schematic.schematica.*
|
||||
#proguard doesnt like it when it cant find our fake schematica classes
|
||||
-dontwarn baritone.utils.schematic.schematica.*
|
||||
|
||||
# copy all necessary libraries into tempLibraries to build
|
||||
|
||||
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with
|
||||
|
@ -54,6 +54,8 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
return build(schematicFile, file, origin);
|
||||
}
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void pause();
|
||||
|
||||
void resume();
|
||||
|
@ -295,6 +295,10 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
||||
logDirect(success ? "Loaded" : "Unable to load");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("schematica")) {
|
||||
baritone.getBuilderProcess().buildOpenSchematic();
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("come")) {
|
||||
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity())));
|
||||
logDirect("Coming");
|
||||
|
@ -35,6 +35,7 @@ import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.PathingCommandContext;
|
||||
import baritone.utils.schematic.AirSchematic;
|
||||
import baritone.utils.schematic.Schematic;
|
||||
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
@ -106,6 +107,20 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpenSchematic() {
|
||||
if (SchematicaHelper.isSchematicaPresent()) {
|
||||
Optional<Tuple<ISchematic, BlockPos>> schematic = SchematicaHelper.getOpenSchematic();
|
||||
if (schematic.isPresent()) {
|
||||
this.build(schematic.get().getFirst().toString(), schematic.get().getFirst(), schematic.get().getSecond());
|
||||
} else {
|
||||
logDirect("No schematic currently open");
|
||||
}
|
||||
} else {
|
||||
logDirect("Schematica is not present");
|
||||
}
|
||||
}
|
||||
|
||||
public void clearArea(BlockPos corner1, BlockPos corner2) {
|
||||
BlockPos origin = new BlockPos(Math.min(corner1.getX(), corner2.getX()), Math.min(corner1.getY(), corner2.getY()), Math.min(corner1.getZ(), corner2.getZ()));
|
||||
int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1;
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 baritone.utils.schematic.schematica;
|
||||
|
||||
import baritone.api.utils.ISchematic;
|
||||
|
||||
import com.github.lunatrius.schematica.client.world.SchematicWorld;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
// TODO: this only works for the default rotation
|
||||
public final class SchematicAdapter implements ISchematic {
|
||||
private final SchematicWorld schematic;
|
||||
|
||||
|
||||
public SchematicAdapter(SchematicWorld schematicWorld) {
|
||||
this.schematic = schematicWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState desiredState(int x, int y, int z) {
|
||||
return schematic.getSchematic().getBlockState(new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int widthX() {
|
||||
return schematic.getSchematic().getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int heightY() {
|
||||
return schematic.getSchematic().getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lengthZ() {
|
||||
return schematic.getSchematic().getLength();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 baritone.utils.schematic.schematica;
|
||||
|
||||
import baritone.api.utils.ISchematic;
|
||||
import com.github.lunatrius.core.util.math.MBlockPos;
|
||||
import com.github.lunatrius.schematica.Schematica;
|
||||
import com.github.lunatrius.schematica.proxy.ClientProxy;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public enum SchematicaHelper {
|
||||
;
|
||||
|
||||
public static boolean isSchematicaPresent() {
|
||||
try {
|
||||
Class.forName(Schematica.class.getName());
|
||||
return true;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<Tuple<ISchematic, BlockPos>> getOpenSchematic() {
|
||||
return Optional.ofNullable(ClientProxy.schematic)
|
||||
.map(world -> {
|
||||
MBlockPos poz = world.position;
|
||||
return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.field_177962_a, poz.field_177960_b, poz.field_177961_c));
|
||||
});
|
||||
}
|
||||
|
||||
private static void meme(Class<?> clazz) throws ClassNotFoundException {}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 com.github.lunatrius.core.util.math;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class MBlockPos extends BlockPos {
|
||||
public int field_177962_a; // x
|
||||
public int field_177960_b; // y
|
||||
public int field_177961_c; // z
|
||||
|
||||
private MBlockPos() {
|
||||
super(6, 6, 6);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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 com.github.lunatrius.schematica;
|
||||
|
||||
import com.github.lunatrius.schematica.proxy.CommonProxy;
|
||||
|
||||
public class Schematica {
|
||||
public static CommonProxy proxy;
|
||||
}
|
@ -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 com.github.lunatrius.schematica.api;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ISchematic {
|
||||
IBlockState getBlockState(BlockPos var1);
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
int getLength();
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 com.github.lunatrius.schematica.client.world;
|
||||
|
||||
import com.github.lunatrius.core.util.math.MBlockPos;
|
||||
import com.github.lunatrius.schematica.api.ISchematic;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class SchematicWorld {
|
||||
private ISchematic schematic;
|
||||
public final MBlockPos position = (MBlockPos)(Object)"cringe";
|
||||
|
||||
public ISchematic getSchematic() {
|
||||
throw new LinkageError("LOL");
|
||||
}
|
||||
}
|
@ -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 com.github.lunatrius.schematica.proxy;
|
||||
|
||||
import com.github.lunatrius.schematica.client.world.SchematicWorld;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
public static SchematicWorld schematic;
|
||||
|
||||
public static EnumFacing orientation;
|
||||
public static EnumFacing axisFlip;
|
||||
public static EnumFacing axisRotation;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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 com.github.lunatrius.schematica.proxy;
|
||||
|
||||
public abstract class CommonProxy {}
|
Loading…
Reference in New Issue
Block a user