Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.7.10] Block.getHarvestLevel(int meta) and Block.getHarvestTool(int meta)

Featured Replies

Posted

Hello

 

I have a question. As I wanted to do a simple research for block harvest levels and block harvest tools, I found that I can't get that information.

Basically I want to create a csv for spreadsheet with as much info from block as possible:

 

 


    try{
            File file = new File("C:\\Temp\\blocks.txt");
            if (!file.exists())
                file.createNewFile();

            PrintWriter w = new PrintWriter(file);

            for (Object aBlockRegistry : Block.blockRegistry) {
                Block block = (Block) aBlockRegistry;
                w.print(block.getUnlocalizedName());
                w.print(",");
                w.print(block.getBlockHardness(null, 0, 0, 0));
                w.print(",");
                Material material = block.getMaterial();
                w.print(material == Material.rock ? "rock" : (material == Material.wood ? "wood" : "unknown"));
                w.print(",");
                w.print(block.getHarvestLevel(0));
                w.print(",");
                w.print(block.getHarvestTool(0));
                w.println();
            }
            w.close();
        } catch (Exception e){
            System.out.println(e.getStackTrace());
        }
[/Code]

 

 

The result looks weird, as harvest level is always -1 and harvest tool is always null

 

[Code]
tile.stairsWood,2.0,wood,-1,null
tile.chest,2.5,wood,-1,null
tile.redstoneDust,0.0,unknown,-1,null
tile.oreDiamond,3.0,rock,-1,null
tile.blockDiamond,5.0,unknown,-1,null
tile.workbench,2.5,wood,-1,null
[/Code]

 

 

What am I doing wrong?

 

I come here to ask only after several hours of struggling, forum browsing and googling. Please be kind :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.