use of io.xol.enklume.nbt.NBTCompound in project chunkstories-core by Hugobros3.
the class Sign method translateSignText.
private void translateSignText(VoxelComponent target, MinecraftChunk minecraftChunk, int x, int y, int z) {
NBTCompound root = minecraftChunk.getRootTag();
if (root == null)
return;
NBTList entitiesList = (NBTList) root.getTag("Level.TileEntities");
// Check it exists and is of the right kind
if (target != null && target instanceof VoxelComponentSignText) {
VoxelComponentSignText signTextComponent = (VoxelComponentSignText) target;
signTextComponent.setSignText("<corresponding sign not found :(>");
for (NBTag element : entitiesList.elements) {
NBTCompound entity = (NBTCompound) element;
NBTString entityId = (NBTString) entity.getTag("id");
int tileX = ((NBTInt) entity.getTag("x")).data;
int tileY = ((NBTInt) entity.getTag("y")).data;
int tileZ = ((NBTInt) entity.getTag("z")).data;
if (entityId.data.toLowerCase().equals("sign") || entityId.data.toLowerCase().equals("minecraft:sign")) {
// System.out.println("Looking up sign data for B:"+x+":"+y+":"+z);
if ((tileX & 0xF) != x || tileY != y || (tileZ & 0xF) != z) {
continue;
}
String text1 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text1")).data);
String text2 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text2")).data);
String text3 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text3")).data);
String text4 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text4")).data);
String textComplete = text1 + "\n" + text2 + "\n" + text3 + "\n" + text4;
signTextComponent.setSignText(textComplete);
System.out.println("OK: " + textComplete);
break;
// ((EntitySign) ((VoxelSign) voxel).getEntity(exported.peekSafely(csCoordinatesX, csCoordinatesY, csCoordinatesZ))).setText(textComplete);
}
// else
// System.out.println("Found "+entityId.data);
}
}
}
Aggregations