Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author

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();

        }

    }

 

}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.