Added mixin to properly handle Long Arrays
This commit is contained in:
parent
52aa0d9b8a
commit
a091c17b83
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -31,6 +31,7 @@
|
|||||||
"MixinStateImplementation",
|
"MixinStateImplementation",
|
||||||
"MixinTabCompleter",
|
"MixinTabCompleter",
|
||||||
"MixinVboRenderList",
|
"MixinVboRenderList",
|
||||||
"MixinWorldClient"
|
"MixinWorldClient",
|
||||||
|
"MixinNBTTagLongArray"
|
||||||
]
|
]
|
||||||
}
|
}
|
27
src/main/java/baritone/utils/accessor/INBTTagLongArray.java
Normal file
27
src/main/java/baritone/utils/accessor/INBTTagLongArray.java
Normal file
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.utils.accessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author rycbar
|
||||||
|
* @since 26.09.2022
|
||||||
|
*/
|
||||||
|
public interface INBTTagLongArray {
|
||||||
|
|
||||||
|
long[] getLongArray();
|
||||||
|
}
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.utils.schematic.format.defaults;
|
package baritone.utils.schematic.format.defaults;
|
||||||
|
|
||||||
import baritone.utils.schematic.StaticSchematic;
|
import baritone.utils.schematic.StaticSchematic;
|
||||||
|
import baritone.utils.accessor.INBTTagLongArray;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.nbt.*;
|
import net.minecraft.nbt.*;
|
||||||
@ -180,14 +181,7 @@ public final class LitematicaSchematic extends StaticSchematic {
|
|||||||
* @return array of Long values.
|
* @return array of Long values.
|
||||||
*/
|
*/
|
||||||
private static long[] getBlockStates() {
|
private static long[] getBlockStates() {
|
||||||
String rawBlockString = Objects.requireNonNull((nbt.getCompoundTag(reg).getCompoundTag(subReg).getTag(blSt))).toString();
|
return ((INBTTagLongArray) nbt.getCompoundTag(reg).getCompoundTag(subReg).getTag(blSt)).getLongArray();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user