Java Code Examples for codechicken.lib.data.MCDataInput#readVarInt()

The following examples show how to use codechicken.lib.data.MCDataInput#readVarInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigTagImpl.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void read(MCDataInput in) {
    if (isCategory()) {
        int numChildren = in.readVarInt();
        for (int i = 0; i < numChildren; i++) {
            String name = in.readString();
            ConfigTagImpl found = children.get(name);
            if (found == null) {
                throw new IllegalArgumentException("read called with data that does not align to this tag, Missing: " + name);
            }
            found.read(in);
        }
    } else {
        value = type.read(in, listType);
    }
}
 
Example 2
Source File: ConfigSyncManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void applyTo(MCDataInput in, ConfigTag parent) {
    SyncState master = SyncState.create(parent);
    Map<String, ConfigTag> lookup = master.syncTags.stream()//
            .collect(Collectors.toMap(ConfigTag::getQualifiedName, Function.identity()));
    int numTags = in.readVarInt();
    for (int i = 0; i < numTags; i++) {
        String ident = in.readString();
        ConfigTag found = lookup.get(ident);
        if (found == null) {
            throw new RuntimeException("Unable to apply server sync, tag does not exist! " + ident);
        }
        found.read(in);
    }
    try {
        parent.runSync(SyncType.CONNECT);
    } catch (SyncException e) {
        throw new RuntimeException("Unable to apply server sync, SyncException thrown!", e);
    }

}
 
Example 3
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    List list = new LinkedList();
    int num = in.readVarInt();
    for (int i = 0; i < num; i++) {
        list.add(listType.read(in, null));
    }
    return list;
}