Radvylf / minecraft-lists

Lists of items, blocks, and more. Updated for each version.
MIT License
15 stars 5 forks source link

Add 1.8 #9

Closed TheKodeToad closed 2 years ago

TheKodeToad commented 2 years ago

Adds all 1.8 blocks and item IDs, for the PVP community. All versions have the same list. Uses slightly cleaner MCP code:

package me.mcblueparrot.data;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.io.FileUtils;

import net.minecraft.block.Block;
import net.minecraft.init.Bootstrap;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.IRegistry;
import net.minecraft.util.RegistryNamespaced;
import net.minecraft.util.ResourceLocation;

public class DataDumper {

    public static void main(String[] args) throws IOException {
        Bootstrap.register();

        Item.registerItems();

        dump(Item.itemRegistry, "items");
        dump(Block.blockRegistry, "blocks");
    }

    private static <T> void dump(RegistryNamespaced<ResourceLocation, T> registry, String name) throws IOException {
        File itemsFile = new File("./" + name + ".txt");
        List<String> items = new ArrayList<String>();
        for(T obj : registry) {
            items.add(registry.getNameForObject(obj).toString());
        }
        Collections.sort(items);
        FileUtils.writeStringToFile(itemsFile, String.join("\n", items), "UTF-8");      
    }

}

It may be useful to also include block variants - as you probably know, in 1.12 and below, blocks have integer variant values, used to determine basic data about the block. It may also be useful to include block IDs, but they were removed from commands in 1.8. In "The Flattening" this was all replaced with block states.