File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
common/src/main/kotlin/com/lambda/util/extension Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,39 @@ package com.lambda.util.extension
2020import net.minecraft.nbt.NbtCompound
2121import net.minecraft.nbt.NbtInt
2222import net.minecraft.nbt.NbtList
23+ import net.minecraft.util.math.Vec3i
2324
2425/* *
2526 * Puts a list of integer into the component, this is not the same as an int array
2627 */
2728fun NbtCompound.putIntList (key : String , vararg values : Int ) {
2829 put(key, values.fold(NbtList ()) { list, value -> list.add(NbtInt .of(value)); list })
2930}
31+
32+ /* *
33+ * Retrieves a vector from a tuple
34+ */
35+ fun NbtCompound.getVector (key : String ): Vec3i {
36+ val compound = getCompound(key)
37+
38+ var x = compound.getInt(" x" )
39+ var y = compound.getInt(" y" )
40+ var z = compound.getInt(" z" )
41+
42+ if (x == 0 && y == 0 && z == 0 ) {
43+ x = compound.getInt(" X" )
44+ y = compound.getInt(" Y" )
45+ z = compound.getInt(" Z" )
46+ }
47+
48+ if (compound.isEmpty) {
49+ val arr = getIntArray(key)
50+ if (arr.size == 3 ) {
51+ x = arr[0 ]
52+ y = arr[1 ]
53+ z = arr[2 ]
54+ }
55+ }
56+
57+ return Vec3i (x, y, z)
58+ }
You can’t perform that action at this time.
0 commit comments