DefCon 121 Share Posted May 29, 2018 (edited) Mine n' Craft This script mines silver/guildat the Al-Kharid mine, then crafts the ore into different type of Jewellyry. It's great for getting some mining and crafting levels. Currently it only supports silver holy symbols, but can quickly modified to suit your needs. It contains no anti-ban whatsoever so use at your own risk. package def.scripts; import org.dreambot.api.methods.MethodProvider; import org.dreambot.api.methods.filter.Filter; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.widget.Widget; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.utilities.impl.Condition; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.items.Item; import org.dreambot.api.wrappers.widgets.WidgetChild; @ScriptManifest(author = "DefCon&Nezz", description = "You've just hit the Mother Load, baby!!",name = "Mine and Craft", version = 1, category = Category.MINING) public class MineNdCraft extends AbstractScript{ private static final Area furnaceArea = new Area(3274,3184,3276,3187,0); private static final Area bankArea = new Area(3267,3164,3271,3170,0); private static final Area mineArea = new Area(3291,3283,3304,3316,0); private static final int[] picks = new int []{}; private static final int furnaceId =24009; JEWELLRY_TYPE ourJewellry = JEWELLRY_TYPE.SYMBOL; boolean justGotHere; public GameObject getRock(){ MethodProvider.log("Looking for rock"); int[] ids; int count =0; for(int id: ourJewellry.metal.rockIds) count+=1; ids = new int[count]; count=0; for(int id: ourJewellry.metal.rockIds){ ids[count]=id; count+=1; } return getGameObjects().closest(new Filter<GameObject>(){ @Override public boolean match(GameObject obj) { for(int id: ids) if(obj.getID()==id) return true; return false; } }); } @Override public void onStart(){ } @Override public int onLoop() { if(getInventory().isFull()){ if(getInventory().contains(ourJewellry.metal.oredId)||getInventory().contains(ourJewellry.metal.metalId)){ //Smithing procedure if(furnaceArea.contains(getLocalPlayer())){ if(getLocalPlayer().isAnimating()){ return 600; } else{ if(justGotHere){ if(MethodProvider.sleepUntil(new Condition(){ @Override public boolean verify() { return getLocalPlayer().isAnimating(); } }, 2200)){ MethodProvider.log("okay now we're animating"); } else{ MethodProvider.log("waited, still not animating."); justGotHere = false; } } else{ if(getInventory().contains(ourJewellry.metal.metalId)){ getInventory().get(ourJewellry.metal.metalId).useOn(getGameObjects().closest(furnaceId)); MethodProvider.sleep(600,1200); getWidgets().getWidget(6).getChild(6).getChild(ourJewellry.childId).interact("Craft all"); MethodProvider.sleepUntil(new Condition(){ @Override public boolean verify() { return getLocalPlayer().isAnimating(); } }, 2200); } else{ getGameObjects().closest(furnaceId).interact("Smelt"); MethodProvider.sleep(600,1200); getKeyboard().type(""+ourJewellry.metal.keyId, false); MethodProvider.sleepUntil(new Condition(){ @Override public boolean verify() { return getLocalPlayer().isAnimating(); } }, 2200); } justGotHere=true; } } } else{ Tile dest = getWalking().getDestination(); if(dest==null || dest.distance()<4 || dest.distance()>20) getWalking().walk(furnaceArea.getRandomTile()); justGotHere=true; } } else{ //Banking procedure if( bankArea.contains(getLocalPlayer())){ if(getBank().isOpen()){ getBank().depositAllExcept(new Filter<Item>(){ @Override public boolean match(Item arg0) { for(int i: picks){ if(i==arg0.getID()) return true; } if(arg0.getID()==ourJewellry.moldId) return true; return false; } }); MethodProvider.sleep(600,1200); } else{ getBank().open(); MethodProvider.sleepUntil(new Condition(){ @Override public boolean verify() { return getBank().isOpen(); } }, 4000); } } else{ Tile dest = getWalking().getDestination(); if(dest==null || dest.distance()<4 || dest.distance()>20) getWalking().walk(bankArea.getRandomTile()); } } } else{ if(mineArea.contains(getLocalPlayer())){ if(getRock()!=null && !getLocalPlayer().isAnimating()){ GameObject rock = getRock(); if(rock.interact("Mine")){ MethodProvider.sleepUntil(new Condition(){ @Override public boolean verify() { return getLocalPlayer().isAnimating(); } }, 4000); } else{ MethodProvider.log("Failed interaction"); } } } else{ Tile dest = getWalking().getDestination(); if(dest==null || dest.distance()<4 || dest.distance()>20) getWalking().walk(mineArea.getRandomTile()); } //Mining procedure } return 0; } } enum ORES{ GOLD(new int[]{7457},442,5,2366),SILVER(new int[]{7457,7490,},442,3,2355); int metalId; int[] rockIds; int oredId; Tile[][] spots; int keyId; ORES(int[] rockIds,int oreId,int keyId, int metalId){ this.rockIds=rockIds; this.oredId=oreId; this.keyId=keyId; this.metalId=metalId; } } enum JEWELLRY_TYPE{ SYMBOL(ORES.SILVER,1599,1,0), EMBLEM(ORES.SILVER,1,1,1), TIARA(ORES.SILVER,1,1,1), GOLD_RING(ORES.SILVER,1,1,1),GOLD_NECKLACE(ORES.SILVER,1,1,1), GOLD_BRACELET(ORES.SILVER,1,1,1),GOLD_AMULET(ORES.SILVER,1,1,1); ORES metal; int moldId; int jewellryId; int childId; JEWELLRY_TYPE(ORES metal,int moldId,int jewellryId,int childId){ this.metal=metal; this.moldId= moldId; this.jewellryId= jewellryId; this.childId= childId; } } Edited May 30, 2018 by DefCon Almonds 1 Link to comment Share on other sites More sharing options...
Hashtag 8670 Share Posted May 29, 2018 Minecraft! Nice to see open source content. Link to comment Share on other sites More sharing options...
CosmicOverrid 0 Share Posted October 20, 2018 Very nice, free and open source script; thanks for the share. Link to comment Share on other sites More sharing options...
choucter 1 Share Posted May 6, 2021 Hi, I'm a newbie trying to learn both Java and the Dreambot language to interface with Runescape. I'm doing this with Java tutorials and also by downloading a few open source Dreambot scripts, and reviewing them with IntelliJ. Needless to say, I'm coming across several deprecated commands and updating them as I go along. I'm stuck with the following statement in this script: return getGameObjects().closest(new Filter<GameObject>() IntelliJ is giving 2 warnings for this: 1) 'getGameObjects()' is deprecated 2) Anonymous new Filter<GameObject>() can be replaced with lambda I've managed to modify a few deprecated 'get' statements to get them working but this particular code line has me beat. Can anyone offer any suggestions? Would be much appreciated to enhance my scripting education. Link to comment Share on other sites More sharing options...
Bonfire 331 Share Posted May 7, 2021 16 minutes ago, choucter said: Hi, I'm a newbie trying to learn both Java and the Dreambot language to interface with Runescape. I'm doing this with Java tutorials and also by downloading a few open source Dreambot scripts, and reviewing them with IntelliJ. Needless to say, I'm coming across several deprecated commands and updating them as I go along. I'm stuck with the following statement in this script: return getGameObjects().closest(new Filter<GameObject>() IntelliJ is giving 2 warnings for this: 1) 'getGameObjects()' is deprecated 2) Anonymous new Filter<GameObject>() can be replaced with lambda I've managed to modify a few deprecated 'get' statements to get them working but this particular code line has me beat. Can anyone offer any suggestions? Would be much appreciated to enhance my scripting education. Hey @choucter, it may be best to make your own thread, but I will still answer your questions. 1. The getGameObjects() method is deprecated, and the GameObjects class should be used instead. For your example, one could do the following: GameObject myGameObject = GameObjects.closest("Tree"); The above code snippet would find the closest GameObject matching the name "Tree". 2. The IDE notifying you that your anonymous Filter can be replaced by a lambda expression is just it letting you know you can shorten your code. Filters are, in essence, lambdas. However, simple Filters can more often than not be replaced by shorter lambda expressions. Below I have provided two code snippets that are identical: GameObject myGameObject = GameObjects.closest(new Filter<GameObject>() { @Override public boolean match(GameObject gameObject) { return gameObject.getName().contains("Anvil"); } }); Using Filters GameObject myGameObject = GameObjects.closest(gameObject -> gameObject.getName().contains("Anvil")); Using a lambda expression Both are equivalent, but using a lambda in this case is more terse and has the same result. If you have further questions, I would suggest creating your own thread or reaching out on the DreamBot discord. Best of luck! Elliott1 and Aeglen 1 1 Link to comment Share on other sites More sharing options...
Elliott1 61 Share Posted May 7, 2021 9 hours ago, Bonfire said: Hey @choucter, it may be best to make your own thread, but I will still answer your questions. 1. The getGameObjects() method is deprecated, and the GameObjects class should be used instead. For your example, one could do the following: GameObject myGameObject = GameObjects.closest("Tree"); The above code snippet would find the closest GameObject matching the name "Tree". 2. The IDE notifying you that your anonymous Filter can be replaced by a lambda expression is just it letting you know you can shorten your code. Filters are, in essence, lambdas. However, simple Filters can more often than not be replaced by shorter lambda expressions. Below I have provided two code snippets that are identical: GameObject myGameObject = GameObjects.closest(new Filter<GameObject>() { @Override public boolean match(GameObject gameObject) { return gameObject.getName().contains("Anvil"); } }); Using Filters GameObject myGameObject = GameObjects.closest(gameObject -> gameObject.getName().contains("Anvil")); Using a lambda expression Both are equivalent, but using a lambda in this case is more terse and has the same result. If you have further questions, I would suggest creating your own thread or reaching out on the DreamBot discord. Best of luck! Spread the knowledge 🧠 Link to comment Share on other sites More sharing options...
choucter 1 Share Posted May 7, 2021 Wow! Thanks for the great explanation, Elliott. I'll definitely be checking this out later today, and adding it to my Java documentation. I can see that this should be a separate thread on coding rather than on the mining script - I'll remember for the next time. Link to comment Share on other sites More sharing options...
choucter 1 Share Posted May 7, 2021 Oops! I notice I should have been thanking Bonfire for that great explanation. Very much appreciated, Bonfire! Link to comment Share on other sites More sharing options...
Elliott1 61 Share Posted May 7, 2021 (edited) 1 hour ago, choucter said: Wow! Thanks for the great explanation, Elliott. I'll definitely be checking this out later today, and adding it to my Java documentation. I can see that this should be a separate thread on coding rather than on the mining script - I'll remember for the next time. No worries mate, happy to help @Bonfire Edited May 7, 2021 by Elliott1 Aeglen 1 Link to comment Share on other sites More sharing options...
donnsuares 0 Share Posted March 15, 2022 (edited) You built your first shelter and survived the first night. Now it's time to literally dig into the game. One of the key mechanics of survival mode is mining. You can play the game without mining (and some players like to challenge themselves by playing the game without mining experience). Still, the experience core of Survival Mode strongly encourages you to dig deep into the Earth for resources. Without access to the abundance of iron and coal trapped in the ground, the game is quite difficult. Once you get the hang of the game, you can choose your own servers, as I did, thanks to https://minecraft.buzz/. Edited March 17, 2022 by donnsuares Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now