diff --git a/src/launch/java/baritone/launch/mixins/MixinNBTTagLongArray.java b/src/launch/java/baritone/launch/mixins/MixinNBTTagLongArray.java new file mode 100644 index 000000000..a4cd739ac --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinNBTTagLongArray.java @@ -0,0 +1,37 @@ +/* + * 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 . + */ + +package baritone.launch.mixins; + +import baritone.utils.accessor.INBTTagLongArray; +import net.minecraft.nbt.NBTTagLongArray; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +/** + * @author rycbar + * @since 26.09.2022 + */ +@Mixin(NBTTagLongArray.class) +public abstract class MixinNBTTagLongArray implements INBTTagLongArray { + + @Accessor("data") + @Override + public abstract long[] getLongArray(); + + +} \ No newline at end of file diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index fdcd14b92..c4b88481c 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -31,6 +31,7 @@ "MixinStateImplementation", "MixinTabCompleter", "MixinVboRenderList", - "MixinWorldClient" + "MixinWorldClient", + "MixinNBTTagLongArray" ] } \ No newline at end of file diff --git a/src/main/java/baritone/utils/accessor/INBTTagLongArray.java b/src/main/java/baritone/utils/accessor/INBTTagLongArray.java new file mode 100644 index 000000000..fe4f0bd87 --- /dev/null +++ b/src/main/java/baritone/utils/accessor/INBTTagLongArray.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +package baritone.utils.accessor; + +/** + * @author rycbar + * @since 26.09.2022 + */ +public interface INBTTagLongArray { + + long[] getLongArray(); +} \ No newline at end of file diff --git a/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java b/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java index 411e1988a..defbd3ea4 100644 --- a/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java +++ b/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java @@ -18,6 +18,7 @@ package baritone.utils.schematic.format.defaults; import baritone.utils.schematic.StaticSchematic; +import baritone.utils.accessor.INBTTagLongArray; import net.minecraft.block.*; import net.minecraft.block.properties.IProperty; import net.minecraft.nbt.*; @@ -180,14 +181,7 @@ public final class LitematicaSchematic extends StaticSchematic { * @return array of Long values. */ private static long[] getBlockStates() { - String rawBlockString = Objects.requireNonNull((nbt.getCompoundTag(reg).getCompoundTag(subReg).getTag(blSt))).toString(); - rawBlockString = rawBlockString.substring(3,rawBlockString.length()-1); - String[] rawBlockArrayString = rawBlockString.split(","); - long[] rawBlockData = new long[rawBlockArrayString.length]; - for (int i = 0; i < rawBlockArrayString.length; i++) { - rawBlockData[i] = Long.parseLong(rawBlockArrayString[i].substring(0,rawBlockArrayString[i].length()-1)); - } - return rawBlockData; + return ((INBTTagLongArray) nbt.getCompoundTag(reg).getCompoundTag(subReg).getTag(blSt)).getLongArray(); } /**