it works but its spaghetti
This commit is contained in:
parent
025f6235f9
commit
76404c8af6
@ -44,6 +44,7 @@ import baritone.utils.PathingCommandContext;
|
||||
import baritone.utils.schematic.MapArtSchematic;
|
||||
import baritone.utils.schematic.SelectionSchematic;
|
||||
import baritone.utils.schematic.SchematicSystem;
|
||||
import baritone.utils.schematic.format.defaults.LitematicaSchematic;
|
||||
import baritone.utils.schematic.litematica.LitematicaHelper;
|
||||
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@ -55,12 +56,15 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -180,18 +184,75 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
@Override
|
||||
public void buildOpenLitematic(int i) {
|
||||
if (LitematicaHelper.isLitematicaPresent()) {
|
||||
//if java.lang.NoSuchMethodError is thrown see comment in SchematicPlacementManager
|
||||
if (LitematicaHelper.hasLoadedSchematic()) {
|
||||
String name = LitematicaHelper.getName(i);
|
||||
File schemFile = LitematicaHelper.getSchematicFile(i);
|
||||
Vec3i origin = LitematicaHelper.getOrigin(i);
|
||||
|
||||
boolean success = build(name, schemFile, origin);
|
||||
if (success) {
|
||||
logDirect(String.format("Building Schematic: %s\nOrigion: %s",name,origin));
|
||||
} else {
|
||||
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
|
||||
|
||||
|
||||
|
||||
try {
|
||||
LitematicaSchematic herbert = new LitematicaSchematic(CompressedStreamTools.readCompressed(new FileInputStream(schemFile)));
|
||||
LitematicaSchematic volker_rainer_fahrenhorst = new LitematicaSchematic(CompressedStreamTools.readCompressed(new FileInputStream(schemFile)));
|
||||
|
||||
net.minecraft.util.Rotation rotation = LitematicaHelper.getRotation(i);
|
||||
net.minecraft.util.Mirror mirror = LitematicaHelper.getMirror(i);
|
||||
|
||||
|
||||
Vec3i gustav = herbert.getMinimumCorner();
|
||||
Vec3i martin = new Vec3i(origin.getX()+gustav.getX(),origin.getY()+gustav.getY(),origin.getZ()+gustav.getZ());
|
||||
int xena = herbert.getX();
|
||||
int yvonne = herbert.getY();
|
||||
int zuse = herbert.getZ();
|
||||
|
||||
for (int brian=0; brian<yvonne; brian++) {
|
||||
for (int carmen=0; carmen<zuse; carmen++) {
|
||||
for (int ariel=0; ariel<xena; ariel++) {
|
||||
int dora;
|
||||
int eleonore;
|
||||
int ferdinand;
|
||||
|
||||
if(mirror== Mirror.LEFT_RIGHT) {
|
||||
dora = ariel; //x stays the same in this transformation
|
||||
eleonore = brian; //y stays the same
|
||||
ferdinand = (zuse-1)-carmen; //[new Z] = ([size Z] - 1(because index starts at 0)) - [original Z]
|
||||
} else if (mirror==Mirror.FRONT_BACK) {
|
||||
dora = (xena-1)-ariel; //[new X] = ([size X] - 1(because index starts at 0)) - [original x]
|
||||
eleonore = brian; //y stays the same
|
||||
ferdinand = carmen; //z stays the same in this transformation
|
||||
} else {
|
||||
dora = ariel; //we dont transform
|
||||
eleonore = brian; //we dont transform
|
||||
ferdinand = carmen; //we dont transform
|
||||
}
|
||||
int turns;
|
||||
switch (rotation) {
|
||||
case CLOCKWISE_90: turns=1; break;
|
||||
case CLOCKWISE_180: turns=2; break;
|
||||
case COUNTERCLOCKWISE_90: turns=3; break;
|
||||
default: turns=0; break;
|
||||
}
|
||||
for (int werner=0; werner<turns; werner++) {
|
||||
int tempx = dora;
|
||||
int tempz = ferdinand;
|
||||
dora = (xena-1) -tempz - (xena-zuse); //[new x] = (([size x] - 1(because index starts at 0)) - ([size x] - [size z])) - [old x]
|
||||
ferdinand = tempx; //[new z] = [old x]
|
||||
}
|
||||
volker_rainer_fahrenhorst.setDirect(dora,eleonore,ferdinand,herbert.getDirect(ariel,brian,carmen));
|
||||
}
|
||||
}
|
||||
}
|
||||
logDirect("congratulation you did it. we dont know yet if your result is right but you have successfully done something");
|
||||
build(name,volker_rainer_fahrenhorst,martin);
|
||||
} catch (IOException e) {
|
||||
logDirect("something went wrong along the way :(");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
logDirect("No schematic currently loaded");
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -209,6 +210,22 @@ public final class LitematicaSchematic extends StaticSchematic {
|
||||
}
|
||||
}
|
||||
|
||||
public Vec3i getMinimumCorner() {
|
||||
return new Vec3i(this.minX, this.minY, this.minZ);
|
||||
}
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
public void setDirect(int x,int y,int z,IBlockState blockState) {
|
||||
this.states[x][z][y] = blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author maruohon
|
||||
* Class from the Litematica mod by maruohon
|
||||
|
@ -19,6 +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 net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.io.File;
|
||||
@ -48,6 +51,12 @@ public final class LitematicaHelper {
|
||||
public static File getSchematicFile(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getSchematicFile();
|
||||
}
|
||||
public static Rotation getRotation(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getRotation();
|
||||
}
|
||||
public static Mirror getMirror(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getMirror();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,6 +17,17 @@
|
||||
|
||||
package fi.dy.masa.litematica.schematic.placement;
|
||||
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
|
||||
public class SchematicPlacement extends SchematicPlacementUnloaded {
|
||||
private Rotation rotation;
|
||||
private Mirror mirror;
|
||||
public Rotation getRotation() {
|
||||
return this.rotation;
|
||||
}
|
||||
public Mirror getMirror() {
|
||||
return this.mirror;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user