auto formatting

This commit is contained in:
rycbar0 2022-10-03 20:13:11 +02:00
parent fc65f22feb
commit 3a5608566e
6 changed files with 65 additions and 60 deletions

View File

@ -26,9 +26,9 @@ import baritone.api.process.IBuilderProcess;
import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType; import baritone.api.process.PathingCommandType;
import baritone.api.schematic.FillSchematic; import baritone.api.schematic.FillSchematic;
import baritone.api.schematic.SubstituteSchematic;
import baritone.api.schematic.ISchematic; import baritone.api.schematic.ISchematic;
import baritone.api.schematic.IStaticSchematic; import baritone.api.schematic.IStaticSchematic;
import baritone.api.schematic.SubstituteSchematic;
import baritone.api.schematic.format.ISchematicFormat; import baritone.api.schematic.format.ISchematicFormat;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.RayTraceUtils; import baritone.api.utils.RayTraceUtils;
@ -42,8 +42,8 @@ import baritone.utils.BaritoneProcessHelper;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.PathingCommandContext; import baritone.utils.PathingCommandContext;
import baritone.utils.schematic.MapArtSchematic; import baritone.utils.schematic.MapArtSchematic;
import baritone.utils.schematic.SelectionSchematic;
import baritone.utils.schematic.SchematicSystem; import baritone.utils.schematic.SchematicSystem;
import baritone.utils.schematic.SelectionSchematic;
import baritone.utils.schematic.format.defaults.LitematicaSchematic; import baritone.utils.schematic.format.defaults.LitematicaSchematic;
import baritone.utils.schematic.litematica.LitematicaHelper; import baritone.utils.schematic.litematica.LitematicaHelper;
import baritone.utils.schematic.schematica.SchematicaHelper; import baritone.utils.schematic.schematica.SchematicaHelper;
@ -183,6 +183,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
/** /**
* Builds the with index 'i' given schematic placement. * Builds the with index 'i' given schematic placement.
*
* @param i index reference to the schematic placement list. * @param i index reference to the schematic placement list.
*/ */
@Override @Override
@ -192,7 +193,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (LitematicaHelper.hasLoadedSchematic()) { if (LitematicaHelper.hasLoadedSchematic()) {
String name = LitematicaHelper.getName(i); String name = LitematicaHelper.getName(i);
try { try {
LitematicaSchematic schematic1 = new LitematicaSchematic(CompressedStreamTools.readCompressed(Files.newInputStream(LitematicaHelper.getSchematicFile(i).toPath())),false); LitematicaSchematic schematic1 = new LitematicaSchematic(CompressedStreamTools.readCompressed(Files.newInputStream(LitematicaHelper.getSchematicFile(i).toPath())), false);
Vec3i correctedOrigin = LitematicaHelper.getCorrectedOrigin(schematic1, i); Vec3i correctedOrigin = LitematicaHelper.getCorrectedOrigin(schematic1, i);
LitematicaSchematic schematic2 = LitematicaHelper.blackMagicFuckery(schematic1, i); LitematicaSchematic schematic2 = LitematicaHelper.blackMagicFuckery(schematic1, i);
build(name, schematic2, correctedOrigin); build(name, schematic2, correctedOrigin);

View File

@ -47,7 +47,7 @@ public final class LitematicaSchematic extends StaticSchematic {
*/ */
public LitematicaSchematic(NBTTagCompound nbtTagCompound, boolean rotated) { public LitematicaSchematic(NBTTagCompound nbtTagCompound, boolean rotated) {
this.nbt = nbtTagCompound; this.nbt = nbtTagCompound;
this.offsetMinCorner = new Vec3i(getMinOfSchematic("x"),getMinOfSchematic("y"),getMinOfSchematic("z")); this.offsetMinCorner = new Vec3i(getMinOfSchematic("x"), getMinOfSchematic("y"), getMinOfSchematic("z"));
this.y = Math.abs(nbt.getCompoundTag("Metadata").getCompoundTag("EnclosingSize").getInteger("y")); this.y = Math.abs(nbt.getCompoundTag("Metadata").getCompoundTag("EnclosingSize").getInteger("y"));
if (rotated) { if (rotated) {
@ -61,36 +61,6 @@ public final class LitematicaSchematic extends StaticSchematic {
fillInSchematic(); fillInSchematic();
} }
/**
* @param s axis.
* @return the lowest coordinate of that axis of the schematic.
*/
private int getMinOfSchematic(String s) {
int n = Integer.MAX_VALUE;
for (String subReg : getRegions(nbt)) {
n = Math.min(n, getMinOfSubregion(nbt, subReg, s));
}
return n;
}
/**
* reads the file data.
*/
private void fillInSchematic() {
for (String subReg : getRegions(nbt)) {
NBTTagList usedBlockTypes = nbt.getCompoundTag("Regions").getCompoundTag(subReg).getTagList("BlockStatePalette", 10);
IBlockState[] blockList = getBlockList(usedBlockTypes);
int bitsPerBlock = getBitsPerBlock(usedBlockTypes.tagCount());
long regionVolume = getVolume(nbt, subReg);
long[] blockStateArray = getBlockStates(nbt, subReg);
LitematicaBitArray bitArray = new LitematicaBitArray(bitsPerBlock, regionVolume, blockStateArray);
writeSubregionIntoSchematic(nbt, subReg, blockList, bitArray);
}
}
/** /**
* @return Array of subregion names. * @return Array of subregion names.
*/ */
@ -203,6 +173,36 @@ public final class LitematicaSchematic extends StaticSchematic {
z < Math.abs(nbt.getCompoundTag("Regions").getCompoundTag(subReg).getCompoundTag("Size").getInteger("z")); z < Math.abs(nbt.getCompoundTag("Regions").getCompoundTag(subReg).getCompoundTag("Size").getInteger("z"));
} }
/**
* @param s axis.
* @return the lowest coordinate of that axis of the schematic.
*/
private int getMinOfSchematic(String s) {
int n = Integer.MAX_VALUE;
for (String subReg : getRegions(nbt)) {
n = Math.min(n, getMinOfSubregion(nbt, subReg, s));
}
return n;
}
/**
* reads the file data.
*/
private void fillInSchematic() {
for (String subReg : getRegions(nbt)) {
NBTTagList usedBlockTypes = nbt.getCompoundTag("Regions").getCompoundTag(subReg).getTagList("BlockStatePalette", 10);
IBlockState[] blockList = getBlockList(usedBlockTypes);
int bitsPerBlock = getBitsPerBlock(usedBlockTypes.tagCount());
long regionVolume = getVolume(nbt, subReg);
long[] blockStateArray = getBlockStates(nbt, subReg);
LitematicaBitArray bitArray = new LitematicaBitArray(bitsPerBlock, regionVolume, blockStateArray);
writeSubregionIntoSchematic(nbt, subReg, blockList, bitArray);
}
}
/** /**
* Writes the file data in to the IBlockstate array. * Writes the file data in to the IBlockstate array.
* *
@ -258,7 +258,7 @@ public final class LitematicaSchematic extends StaticSchematic {
* @param z position relative to the minimum corner of the schematic. * @param z position relative to the minimum corner of the schematic.
* @param blockState new blockstate of the block at this position. * @param blockState new blockstate of the block at this position.
*/ */
public void setDirect(int x,int y,int z,IBlockState blockState) { public void setDirect(int x, int y, int z, IBlockState blockState) {
this.states[x][z][y] = blockState; this.states[x][z][y] = blockState;
} }

View File

@ -51,7 +51,7 @@ public final class LitematicaHelper {
* @return if there are loaded schematics. * @return if there are loaded schematics.
*/ */
public static boolean hasLoadedSchematic() { public static boolean hasLoadedSchematic() {
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().size()>0; return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().size() > 0;
} }
/** /**
@ -67,11 +67,7 @@ public final class LitematicaHelper {
* @return the world coordinates of the schematic origin. This can but does not have to be the minimum corner. * @return the world coordinates of the schematic origin. This can but does not have to be the minimum corner.
*/ */
public static Vec3i getOrigin(int i) { public static Vec3i getOrigin(int i) {
int x,y,z; return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin();
x=DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin().getX();
y=DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin().getY();
z=DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin().getZ();
return new Vec3i(x,y,z);
} }
/** /**
@ -121,7 +117,7 @@ public final class LitematicaHelper {
switch (mirror) { switch (mirror) {
case FRONT_BACK: case FRONT_BACK:
case LEFT_RIGHT: case LEFT_RIGHT:
switch ((mirror.ordinal()*2+rotation.ordinal())%4) { switch ((mirror.ordinal() * 2 + rotation.ordinal()) % 4) {
case 1: case 1:
correctedOrigin = new Vec3i(x + (sz - mz), y + my, z + (sx - mx)); correctedOrigin = new Vec3i(x + (sz - mz), y + my, z + (sx - mx));
break; break;
@ -165,7 +161,7 @@ public final class LitematicaHelper {
public static Vec3i doMirroring(Vec3i in, int sizeX, int sizeZ, Mirror mirror) { public static Vec3i doMirroring(Vec3i in, int sizeX, int sizeZ, Mirror mirror) {
int xOut = in.getX(); int xOut = in.getX();
int zOut = in.getZ(); int zOut = in.getZ();
if(mirror == Mirror.LEFT_RIGHT) { if (mirror == Mirror.LEFT_RIGHT) {
zOut = sizeZ - in.getZ(); zOut = sizeZ - in.getZ();
} else if (mirror == Mirror.FRONT_BACK) { } else if (mirror == Mirror.FRONT_BACK) {
xOut = sizeX - in.getX(); xOut = sizeX - in.getX();
@ -191,14 +187,14 @@ public final class LitematicaHelper {
* @return get it out rotated and mirrored. * @return get it out rotated and mirrored.
*/ */
public static LitematicaSchematic blackMagicFuckery(LitematicaSchematic schemIn, int i) { public static LitematicaSchematic blackMagicFuckery(LitematicaSchematic schemIn, int i) {
LitematicaSchematic tempSchem = schemIn.getCopy(LitematicaHelper.getRotation(i).ordinal()%2==1); LitematicaSchematic tempSchem = schemIn.getCopy(LitematicaHelper.getRotation(i).ordinal() % 2 == 1);
for (int yCounter=0; yCounter<schemIn.getY(); yCounter++) { for (int yCounter = 0; yCounter < schemIn.getY(); yCounter++) {
for (int zCounter=0; zCounter<schemIn.getZ(); zCounter++) { for (int zCounter = 0; zCounter < schemIn.getZ(); zCounter++) {
for (int xCounter=0; xCounter<schemIn.getX(); xCounter++) { for (int xCounter = 0; xCounter < schemIn.getX(); xCounter++) {
Vec3i xyzHolder = new Vec3i(xCounter, yCounter, zCounter); Vec3i xyzHolder = new Vec3i(xCounter, yCounter, zCounter);
xyzHolder = LitematicaHelper.doMirroring(xyzHolder, schemIn.getX() - 1, schemIn.getZ() - 1, LitematicaHelper.getMirror(i)); xyzHolder = LitematicaHelper.doMirroring(xyzHolder, schemIn.getX() - 1, schemIn.getZ() - 1, LitematicaHelper.getMirror(i));
for (int turns = 0; turns < LitematicaHelper.getRotation(i).ordinal(); turns++) { for (int turns = 0; turns < LitematicaHelper.getRotation(i).ordinal(); turns++) {
if ((turns%2)==0) { if ((turns % 2) == 0) {
xyzHolder = LitematicaHelper.rotate(xyzHolder, schemIn.getX() - 1, schemIn.getZ() - 1); xyzHolder = LitematicaHelper.rotate(xyzHolder, schemIn.getX() - 1, schemIn.getZ() - 1);
} else { } else {
xyzHolder = LitematicaHelper.rotate(xyzHolder, schemIn.getZ() - 1, schemIn.getX() - 1); xyzHolder = LitematicaHelper.rotate(xyzHolder, schemIn.getZ() - 1, schemIn.getX() - 1);

View File

@ -22,9 +22,11 @@ import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager;
public class DataManager { public class DataManager {
public static final DataManager INSTANCE = new DataManager(); public static final DataManager INSTANCE = new DataManager();
private final SchematicPlacementManager schematicPlacementManager = new SchematicPlacementManager(); private final SchematicPlacementManager schematicPlacementManager = new SchematicPlacementManager();
private static DataManager getInstance() { private static DataManager getInstance() {
return INSTANCE; return INSTANCE;
} }
public static SchematicPlacementManager getSchematicPlacementManager() { public static SchematicPlacementManager getSchematicPlacementManager() {
return getInstance().schematicPlacementManager; return getInstance().schematicPlacementManager;
} }

View File

@ -23,9 +23,11 @@ import net.minecraft.util.Rotation;
public class SchematicPlacement extends SchematicPlacementUnloaded { public class SchematicPlacement extends SchematicPlacementUnloaded {
private Rotation rotation; private Rotation rotation;
private Mirror mirror; private Mirror mirror;
public Rotation getRotation() { public Rotation getRotation() {
return this.rotation; return this.rotation;
} }
public Mirror getMirror() { public Mirror getMirror() {
return this.mirror; return this.mirror;
} }

View File

@ -24,15 +24,19 @@ import java.io.File;
public class SchematicPlacementUnloaded { public class SchematicPlacementUnloaded {
protected String name = "?"; protected String name = "?";
@Nullable protected File schematicFile; @Nullable
protected File schematicFile;
protected BlockPos origin = BlockPos.ORIGIN; protected BlockPos origin = BlockPos.ORIGIN;
public String getName() { public String getName() {
return this.name; return this.name;
} }
@Nullable @Nullable
public File getSchematicFile() { public File getSchematicFile() {
return this.schematicFile; return this.schematicFile;
} }
public BlockPos getOrigin() { public BlockPos getOrigin() {
return this.origin; return this.origin;
} }