Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Get block by name and modid


SteamPunk_Devil
 Share

Recommended Posts

now that GameRegistry#findBlock() is deprecated what is the best way to get a block by its modid and name?  

 

 public static void addStructure(String file) {
        JSONParser parser = new JSONParser();
        try {
            Object json = parser.parse(new FileReader(file));
            JSONObject jsonObject = (JSONObject) json;
            String name = (String) jsonObject.get("Name");
            String village = (String) jsonObject.get("Village");
            Map<Integer,Block> legend = new HashMap<Integer,Block>();
            JSONArray Legend = (JSONArray) jsonObject.get("Legend");
            //Iterator<String> iterator = Legend.iterator();
            int i = 1;
            Legend.forEach( (a)-> {
                String b;
                b = a.toString();
                String[] bl = b.split(":");
                //legend.put(i);
                String modid = bl[0];
                String block = bl[1];
                System.out.println(block + modid);
                Block bk = GameRegistry.findBlock(modid, block);
                System.out.println(bk);
                //i =+ 1;
            });
            System.out.println("Loading Structure: " + name);
            //worldObject newWorldObject = new worldObject(name, village,);
        }catch (Exception e){
            e.printStackTrace();
        }

 

Edited by SteamPunk_Devil
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.