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.

[Snippet] Ore & Smithing Bar data

Featured Replies

Example:

	public static void main(String[] args) {
		Map<Ore, Integer> o = SmithingBar.ADAMANTITE.getOres();
		System.out.println("In order to make an adamantite bar I need: ");
		for (Ore ore : o.keySet()) {
			System.out.println("\t" + o.get(ore) + " " + ore);
		}
		System.out.println("... and " +SmithingBar.ADAMANTITE.getRequiredSmithingLevel() + " smithing.");
	}

226b62edfa5239288be65d33faf8a5ce.png

Ore enum:

public enum Ore {

	COPPER("Copper ore"),
	TIN("Tin ore"),
	BLURITE("Blurite ore"),
	IRON("Iron ore"),
	SILVER("Silver ore"),
	COAL("Coal ore"),
	GOLD("Gold ore"),
	MITHRIL("Mithril ore"),
	ADAMANTITE("Adamantite ore"),
	RUNITE("Runite ore");
	
	private String name;
	
	private Ore(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	@Override
	public String toString() {
		return getName();
	}
	
}

SmithingBar enum:

package org.botre.data;

import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;

public enum SmithingBar {
	
	BRONZE("Bronze bar", 1),
	BLURITE("Blurite bar", 8),
	IRON("Iron bar", 15),
	SILVER("Silver bar", 20),
	STEEL("Steel bar", 30),
	GOLD("Gold bar", 40),
	MITHRIL("Mithril bar", 50),
	ADAMANTITE("Adamantite bar", 70),
	RUNITE("Runite bar", 85);
	
	private static final Map<SmithingBar, Map<Ore, Integer>> ORE_RECIPES = Collections.unmodifiableMap(initOres());
	
	private String name;
	private int requiredSmithingLevel;
	
	private SmithingBar(String name, int requiredSmithingLevel) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	public int getRequiredSmithingLevel() {
		return requiredSmithingLevel;
	}
	
	public Map<Ore, Integer> getOres() {
		return ORE_RECIPES.get(this);
	}
	
	@Override
	public String toString() {
		return getName();
	}

	private static Map<SmithingBar, Map<Ore, Integer>> initOres() {
		Map<SmithingBar, Map<Ore, Integer>> map = new EnumMap<>(SmithingBar.class);
		for (SmithingBar bar : values()) {
			Map<Ore, Integer> ores = new EnumMap<>(Ore.class);
			switch (bar) {
			case BRONZE:
				ores.put(Ore.COPPER, 1);
				ores.put(Ore.TIN, 1);
				break;
			case BLURITE:
				ores.put(Ore.BLURITE, 1);
				break;
			case IRON:
				ores.put(Ore.IRON, 1);
				break;
			case SILVER:
				ores.put(Ore.SILVER, 1);
				break;
			case STEEL:
				ores.put(Ore.IRON, 1);
				ores.put(Ore.COAL, 2);
				break;
			case GOLD:
				ores.put(Ore.GOLD, 1);
				break;
			case MITHRIL:
				ores.put(Ore.MITHRIL, 1);
				ores.put(Ore.COAL, 4);
				break;
			case ADAMANTITE:
				ores.put(Ore.ADAMANTITE, 1);
				ores.put(Ore.COAL, 6);
				break;
			case RUNITE:
				ores.put(Ore.RUNITE, 1);
				ores.put(Ore.COAL, 8);
				break;
			}
			map.put(bar, ores);
		}
		return map;
	}

	
}

Good and clean code release, you planning on releasing a free/premium smithing script maybe too? Or just giving our a release related to smithing?

 

Either way I'm liking this nice clean code style.

Edited by MegaManAlpha

  • Author

Good and clean code release, you planning on releasing a free/premium smithing script maybe too? Or just giving our a release related to smithing?

 

Either way I'm liking this nice clean code style.

 

Needed this data for the Superheat component of my Magic script, figured maybe someone else could benefit from it too :p

 

The data makes writing a smelter a matter of minutes though:

package org.botre.script;

import java.util.Map;

import org.botre.data.Ore;
import org.botre.data.SmithingBar;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;

//MF
public class SmeltingScript extends Script {

	private SmithingBar bar = SmithingBar.STEEL;
	private Map<Ore, Integer> ores = bar.getOres();
	private int barsPerInventory =  -1;
	
	@Override
	public void onStart() throws InterruptedException {
		super.onStart();
		//Find amount of bars that can fit in one 28-slot inventory.
		for (Ore ore : ores.keySet()) {
			barsPerInventory += ores.get(ore);
		}
		barsPerInventory = 28 / barsPerInventory;
	}
	
	@Override
	public int onLoop() throws InterruptedException {
		boolean bank = false;
		for (Ore ore : ores.keySet()) {
			//Bank if inventory does not contain at least enough ores to smelt one bar.
			if(getInventory().getAmount(ore.getName()) < ores.get(ore)) {
				bank = true;
				break;
			}
		}
		if(bank) {
			if(getBank().open()) {
				//Deposit all bars.
				if(getBank().depositAll(bar.getName())) {
					//Withdraw ores.
					for (Ore ore : ores.keySet()) {
						int amount = barsPerInventory * ores.get(ore);
						if(getInventory().getAmount(ore.getName()) < amount) {
							getBank().withdraw(ore.getName(), (int) (amount - getInventory().getAmount(ore.getName())));
						}
					}
				}
			}
			else {
				//Walk to bank.
			}
		}
		else {
			RS2Object furnace = getObjects().closest("Furnace");
			if(furnace != null && furnace.exists()) {
				// Operate furnace.
			}
			else {
				//Walk to furnace.
			}
		}
		return 500;
	}

}

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.