Search in sources :

Example 1 with MetaData

use of com.builtbroken.mc.framework.block.meta.MetaData in project Engine by VoltzEngine-Project.

the class JsonBlockProcessor method readMeta.

/**
     * Reads the meta data stored in the subtypes entry
     *
     * @param block - meta block, unregistered
     * @param array - array of subtypes
     */
public void readMeta(BlockMeta block, JsonArray array, List<IJsonGenObject> objectList) {
    //Loop every entry in the array, each entry should be meta values
    for (int i = 0; i < array.size() && i < 16; i++) {
        JsonObject json = array.get(i).getAsJsonObject();
        MetaData meta = new MetaData();
        //Reads the meta entry and then returns the meta to assign
        int m = readMetaEntry(block, meta, json, objectList);
        //Meta of -1 is invalid
        if (m != -1) {
            //Meta is locked to 0-15
            if (m >= 0 && m < 16) {
                //Prevent overriding by mistake
                if (block.metaDataValues[m] == null) {
                    meta.index = m;
                    block.metaDataValues[m] = meta;
                } else {
                    throw new IllegalArgumentException("JsonBlockProcessor: Meta value[" + m + "] was overridden inside the same file for block " + block.data.name);
                }
            } else {
                throw new IllegalArgumentException("JsonBlockProcessor: Meta values are restricted from 0 to 15");
            }
        } else {
            throw new IllegalArgumentException("JsonBlockProcessor: Each meta entry requires the value 'meta' of type Integer");
        }
    }
}
Also used : MetaData(com.builtbroken.mc.framework.block.meta.MetaData) JsonObject(com.google.gson.JsonObject)

Aggregations

MetaData (com.builtbroken.mc.framework.block.meta.MetaData)1 JsonObject (com.google.gson.JsonObject)1