Posted April 14, 20178 yr 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 April 14, 20178 yr by SteamPunk_Devil
April 14, 20178 yr Block.getBlockFromName("minecraft:dirt"); catch(Exception e) { } Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).
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.