Jump to content

bongotezz

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by bongotezz

  1. Hello I've been working on learning how to generate structures in the world from schematic files. I found the java library jnbt and was able to get it to work for some things but the tile entity list is not in the correct format that Minecraft likes for it's NBT Compound tags. I could parse the jnbt output myself but it seems like a lot of overhead that i shouldn't be doing. I should be using the nbt classes built into Minecraft. During my many searches i find old code such as: short width = nbt.getShort("Width"); short height = nbt.getShort("Height"); short length = nbt.getShort("Length"); The authors indicate that minecraft has it's own built in nbt support but this code no longer works. I found the net.minecraft.nbt.* classes and looked through them. I found that i can send my input stream to nbt.CompressedStreamTools.readCompressed and get a NBTTagCompound returned. I assume this would be for the entire schematic. After this I'm not sure what to do. I've looked through the nbt classes and can't find anything that will accept either the input stream or the NBTTagCompound and return width, height, length, block and meta data arrays and the 2 entity lists. Does anyone have any guidance for me? Thanks in advance. Bongo
  2. JNBT is a library that allows you to read them. i've been able to read, length,width,height, the array of block IDs, and the array of meta data IDs. I'm still trying to figure out entities and tileentities. I'm kind of lost on those. Here's the code example i found to use with JNBT. import java.io.File; import java.io.FileInputStream; import java.util.List; import java.util.Map; import org.jnbt.ByteArrayTag; import org.jnbt.CompoundTag; import org.jnbt.ListTag; import org.jnbt.NBTInputStream; import org.jnbt.ShortTag; import org.jnbt.Tag; public class HelloWorld { private static Tag getChildTag(Map<String, Tag> items, String key, Class<? extends Tag> expected) { Tag tag = items.get(key); return tag; } public static void main(String[] args) { try { File f = new File("Small Temple.schematic"); FileInputStream fis = new FileInputStream(f); NBTInputStream nbt = new NBTInputStream(fis); CompoundTag backuptag = (CompoundTag) nbt.readTag(); Map<String, Tag> tagCollection = backuptag.getValue(); short width = (Short)getChildTag(tagCollection, "Width", ShortTag.class).getValue(); short height = (Short) getChildTag(tagCollection, "Height", ShortTag.class).getValue(); short length = (Short) getChildTag(tagCollection, "Length", ShortTag.class).getValue(); byte[] blocks = (byte[]) getChildTag(tagCollection, "Blocks", ByteArrayTag.class).getValue(); byte[] data = (byte[]) getChildTag(tagCollection, "Data", ByteArrayTag.class).getValue(); List entities = (List) getChildTag(tagCollection, "Entities", ListTag.class).getValue(); List tileentities = (List) getChildTag(tagCollection, "TileEntities", ListTag.class).getValue(); nbt.close(); fis.close(); System.out.println(entities); } catch (Exception e) { e.printStackTrace(); } } }
  3. Hello I'm new to modding. Been learning a lot but I hit a roadblock. I can't seem to read information from schematic files. I want to make structures but not if i have to code it one block at a time. I want to be able to automate it. All of the code examples i've found don't appear to work. It might just be my lack of knowledge. Can anyone provide me with assistance? Thank you in advance Bongo
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.