Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

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.

Mining rocks with ore [No IDs]

Featured Replies

import org.osbot.rs07.api.model.Entity;

public enum Rock {
    CLAY(new short[]{6705}),
    COPPER(new short[]{4645, 4510}),
    TIN(new short[]{53}),
    IRON(new short[]{2576}),
    SILVER(new short[]{74}),
    COAL(new short[]{10508}),
    GOLD(new short[]{8885}),
    MITHRIL(new short[]{-22239}),
    ADAMANTITE(new short[]{21662}),
    RUNITE(new short[]{-31437});

    private short[] colours;

    Rock(final short[] colours) {
        this.colours = colours;
    }

    public boolean hasOre(final Entity rockEntity) {
        if (rockEntity.getDefinition() == null) {
            return false;
        }

        short[] colours = rockEntity.getDefinition().getModifiedModelColors();

        if (colours == null) {
            return false;
        }

        for (short rockColour : this.colours) {
            for (short entityColour : colours) {
                if (rockColour == entityColour) {
                    return true;
                }
            }
        }
        return false;
    }
}

 

Usage:
 

RS2Object tinRock = getObjects().closest(obj -> Rock.TIN.hasOre(obj));

 

Edited by Explv

  • Author

This takes long.

 

If you don't need the names you can make a method without predefined id's.

 

This takes long?

 

Care to elaborate?

This takes long?

 

Care to elaborate?

 

It takes long from the first use of this method in april 2014 to the first snippet biggrin.png.

 

Anyone interested?

Edited by Soldtodie

  • Author

It takes long from the first use of this method in april 2014 to the first snippet biggrin.png.

 

Anyone interested?

 

I don't really understand what you are saying...

 

But if you think there is a better method that is as concise as this one, I would be interested to see it.

A method for checking if the rock is mined.

public boolean isMined(RS2Object rock) {
            if(rock != null) {
                /* Doesn't exist anymore.
                if(rock.getName().equals("Pile of Rock")) {
                    return rock.getHeight() <= 24;
                }
                */
                short[] col = rock.getDefinition().getModifiedModelColors();
                if(col == null) {
                    return true;
                } else if(col.length == 1) {
                    return col[0] == 6040; // Ok, you need one predefined color id because of the three different rock styles.
                } else {
                    return col[0] == col[1];
                }
            }
            return true;
        }

I prefer to select and save the rock positions.

It's faster because you don't have to check every rock in your neighborhood.

  • Author

A method for checking if the rock is mined.

public boolean isMined(RS2Object rock) {
            if(rock != null) {
                /* Doesn't exist anymore.
                if(rock.getName().equals("Pile of Rock")) {
                    return rock.getHeight() <= 24;
                }
                */
                short[] col = rock.getDefinition().getModifiedModelColors();
                if(col == null) {
                    return true;
                } else if(col.length == 1) {
                    return col[0] == 6040; // Ok, you need one predefined color id because of the three different rock styles.
                } else {
                    return col[0] == col[1];
                }
            }
            return true;
        }

I prefer to select and save the rock positions.

It's faster because you don't have to check every rock in your neighborhood.

 

Have you not considered the case of an AIO miner where the location is not fixed?

 

It takes far longer to record the positions of every rock in the game than it does to record 1 colour per rock.

 

Checking "every rock in your neighborhood" takes such a short amount of time that optimising it is pointless.

 

If you are finding a rock based on its position, you are still checking "every rock in your neighborhood" to find the object at that position.

 

The solution I posted is a global solution, it doesn't require recording rock positions, and it doesn't require recording IDs.

 

Just sayin' :doge:

Have you not considered the case of an AIO miner where the location is not fixed?

 

It takes far longer to record the positions of every rock in the game than it does to record 1 colour per rock.

 

Checking "every rock in your neighborhood" takes such a short amount of time that optimising it is pointless.

 

If you are finding a rock based on its position, you are still checking "every rock in your neighborhood" to find the object at that position.

 

The solution I posted is a global solution, it doesn't require recording rock positions, and it doesn't require recording IDs.

 

Just sayin' doge.png

 

That the user select the rocks.

 

 

 

If you are finding a rock based on its position, you are still checking "every rock in your neighborhood" to find the object at that position.

 

No you haven't.

 

2050e3c18069a21f65a3334748e3635e.png

Edited by Soldtodie

  • Author

That the user select the rocks.

 

 

No you haven't.

 

2050e3c18069a21f65a3334748e3635e.png

 

Ok I get you now. The user selects the rock and you store it.

 

Still... 18ms.... meh :doge:

  • Author

0-1ms is better tongue.png

 

Its unnoticeable :P

 

And it is less convenient for the user to manually select the rocks they want to mine.

 

Either way... both viable solutions :)

Its unnoticeable tongue.png

And it is less convenient for the user to manually select the rocks they want to mine.

Either way... both viable solutions smile.png

I am not saying that your solution is bad, but with saving position you can add next spawning rock and then you must update all rocks every few seconds/ms and then the time could be noticeable.

Edited by Soldtodie

  • 1 year later...

method:

public RS2Object getRockWithOre(Rock rock){

    return getObjects().closest(obj -> {

        short[] colours = obj.getDefinition().getModifiedModelColors();

        if(colours != null){

            for(short c : colours){

                if(c == rock.COLOUR) return true;
            }
        }
        return false;
    });
}

 

This method's throwing up some errors for me. What is obj? Doesn't look like it's defined anywhere. It also doesn't like the syntax you've written with the code you written after the ->.

These -> {} are lambda expressions you can use them if you import java.util.functions if I can recall correctly. These expressions can be used in various ways to save more lines of code. I am not 100℅ sure if you have to import something.

Edit: check here for more info http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html

Edited by Xerifos

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.