1
0
mirror of https://github.com/LOOHP/Limbo.git synced 2026-06-08 14:11:44 +00:00
This commit is contained in:
LOOHP
2021-04-06 21:14:05 +08:00
parent 05cfdb73a9
commit 6d14314bd9
126 changed files with 191394 additions and 0 deletions
@@ -0,0 +1,41 @@
package com.loohp.limbo.utils;
import net.querz.nbt.tag.CompoundTag;
public class SchematicConvertionUtils {
public static CompoundTag toTileEntityTag(CompoundTag tag) {
int[] pos = tag.getIntArray("Pos");
tag.remove("Pos");
tag.remove("Id");
tag.putInt("x", pos[0]);
tag.putInt("y", pos[1]);
tag.putInt("z", pos[2]);
return tag;
}
public static CompoundTag toBlockTag(String input) {
int index = input.indexOf("[");
CompoundTag tag = new CompoundTag();
if (index < 0) {
tag.putString("Name", new NamespacedKey(input).toString());
return tag;
}
tag.putString("Name", new NamespacedKey(input.substring(0, index)).toString());
String[] states = input.substring(index + 1, input.lastIndexOf("]")).replace(" ", "").split(",");
CompoundTag properties = new CompoundTag();
for (String state : states) {
String key = state.substring(0, state.indexOf("="));
String value = state.substring(state.indexOf("=") + 1);
properties.putString(key, value);
}
tag.put("Properties", properties);
return tag;
}
}