Thread: [317] Need help with something probably simple lol

Results 1 to 7 of 7
  1. #1 [317] Need help with something probably simple lol 
    Registered Member Lil Peep's Avatar
    Join Date
    Oct 2012
    Posts
    881
    Thanks given
    234
    Thanks received
    58
    Rep Power
    0
    Base: 317?

    What you need help with:

    I'm creating a new mining base, and I can't figure out how to grab the object id for my ore from actionhandler. I'm wanting to do something like this:

    PS: objectType is a parameter in the firstObjectCLick method.
    Code:
    case 1: // copper
    case 2: // tin
    case 3: // runite
    player.getMining().mineRock(player, objectType);
    break;
    and my class:

    Code:
    package com.vermillion.content.skills;
    
    import com.vermillion.Constants;
    import com.vermillion.event.CycleEvent;
    import com.vermillion.event.CycleEventContainer;
    import com.vermillion.event.CycleEventHandler;
    import com.vermillion.model.players.Client;
    import com.vermillion.util.Misc;
    
    /**
     * Mining.java
     * 
     * Handles all data associated with Mining.
     * 
     * @author Justin Wilson
     */
    public class NewMining {
    	
    	/**
    	 * Handles Ore data
    	 * @param rockId, oreId, levelReq, oreExp, oreName
    	 */
    	private enum OreData {
    		ADAMANTITE(2104, 449, 70, 95, "adamantite"),
    		BLURITE(2110, 668, 10, 17.5, "blurite"),
    		COAL(2096, 453, 30, 50, "coal"),
    		COPPER(2090, 436, 1, 17.5, "copper"),
    		GOLD(2098, 444, 40, 65, "gold"),
    		IRON(2092, 440, 15, 35, "iron"),
    		MITHRIL(2103, 447, 55, 80, "mithril"),
    		RUNITE(2106, 451, 85, 125, "runite"),
    		SILVER(2100, 442, 20, 40, "silver"),
    		TIN(2094, 438, 1, 17.5, "tin");	
    		
    		private int rockId, oreId, levelReq;
    		private double oreExp;
    		private String oreName;
    		
    		private OreData(final int rockId, final int oreId, final int levelReq, final double oreExp, final String oreName) {
    			this.rockId = rockId;
    			this.oreId = oreId;
    			this.levelReq = levelReq;
    			this.oreExp = oreExp;
    			this.oreName = oreName;
    		}
    		
    		private int getRockId() {
    			return rockId;
    		}
    		
    		private int getOreId() {
    			return oreId;
    		}
    		
    		private int getLevelReq() {
    			return levelReq;
    		}
    		
    		private double getOreExp() {
    			return oreExp;
    		}
    		
    		private String getOreName() {
    			return oreName;
    		}
    	}
    	
    	/**
    	 * Handles Pickaxe data
    	 * @param pickaxeId, levelReq, pickaxeTimer, emoteId
    	 */
    	private enum PickaxeData {
    		ADAMANT(1273, 31, 0, 628),
    		BRONZE(1265, 1, 0, 625),
    		IRON(1267, 1, 0, 626),
    		MITHRIL(1271, 21, 0, 629),
    		RUNE(1275, 41, 0, 624),
    		STEEL(1269, 6, 0, 627);
    		
    		private int pickaxeId, levelReq, pickaxeTimer, emoteId;
    		
    		private PickaxeData(final int pickaxeId, final int levelReq, final int pickaxeTimer, final int emoteId) {
    			this.pickaxeId = pickaxeId;
    			this.levelReq = levelReq;
    			this.pickaxeTimer = pickaxeTimer;
    			this.emoteId = emoteId;
    		}
    		
    		private int getPickaxeId() {
    			return pickaxeId;
    		}
    		
    		private int getLevelReq() {
    			return levelReq;
    		}
    		
    		private int getPickaxeTimer() {
    			return pickaxeTimer;
    		}
    		
    		private int getEmoteId() {
    			return emoteId;
    		}
    	}
    
    	public void mineRock(final Client player, final int objectType) {
    		if (player.trainingMining || player.getItems().freeSlots() > 0)
    			return;
    		for (final PickaxeData pickaxeData : PickaxeData.values()) {
    			for (final OreData oreData : OreData.values()) {
    						
    						if (player.getItems().playerHasItem(pickaxeData.getPickaxeId()) || player.playerEquipment[player.playerWeapon] == pickaxeData.getPickaxeId() && player.playerLevel[player.playerMining] >= oreData.getLevelReq()) {
    							player.trainingMining = true;
    							player.startAnimation(pickaxeData.getEmoteId());
    							player.getItems().addItem(oreData.getOreId(), 1);
    							player.getPA().addSkillXP(oreData.getOreExp() * Constants.MINING_EXPERIENCE, player.playerMining);
    						}
    						CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
    							@Override
    							public void execute(CycleEventContainer container) {
    								if (!player.getItems().playerHasItem(pickaxeData.getPickaxeId()) || player.trainingMining == false)
    									container.stop();
    								
    										player.startAnimation(pickaxeData.getEmoteId());
    										player.getItems().addItem(oreData.getOreId(), 1);
    										player.getPA().addSkillXP(oreData.getOreExp() * Constants.MINING_EXPERIENCE, player.playerMining);
    							}
    							@Override
    							public void stop() {
    								player.startAnimation(-1);
    								player.trainingMining = false;
    							}
    						}, 3 + Misc.random(pickaxeData.getPickaxeTimer()));
    			}
    		}
    	}
    
    }
    Some code is probably redundant. I would like to know how to have the object clicked affect which ore you mine/exp etc. I'm not sure if I did this right. I'm probably overthinking this, rep+thanks to whoever helps lol

    PS: conventions are bad and I don't know why. Making the code unreadable on this post lmao
    Attached image Attached image Attached image Attached image Attached image
    Reply With Quote  
     

  2. #2  
    Banned [317] Need help with something probably simple lol Market Banned


    Join Date
    Jan 2011
    Age
    26
    Posts
    3,112
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    im confused... what do you need help with? just print off the object id using a logger or System.out/System.err

    EDIT: wait, what happens when you currently click the ore?
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    What do you have in firstclickobject? Don't tell me you have case 1 case 2 and so forth as shown, as I'm pretty sure the switch is for objectType which should be the id of the object
    Reply With Quote  
     

  4. #4  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    loop through your enum values, if the objectType equals the object id, input that rock type for your method.

    also;

    Code:
    ADAMANTITE(2104, 449, 70, 95, "adamantite"),
    you don't need the last parameter. enum.value.toString() will return what you're looking for.

    loop through your enum values, if the objectType equals the object id, input that rock type for your method.

    also;

    Code:
    ADAMANTITE(2104, 449, 70, 95, "adamantite"),
    you don't need the last parameter. enum.value.toString() will return what you're looking for.

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  5. #5  
    Registered Member Lil Peep's Avatar
    Join Date
    Oct 2012
    Posts
    881
    Thanks given
    234
    Thanks received
    58
    Rep Power
    0
    Quote Originally Posted by Eclipse View Post
    loop through your enum values, if the objectType equals the object id, input that rock type for your method.

    also;

    Code:
    ADAMANTITE(2104, 449, 70, 95, "adamantite"),
    you don't need the last parameter. enum.value.toString() will return what you're looking for.

    loop through your enum values, if the objectType equals the object id, input that rock type for your method.

    also;

    Code:
    ADAMANTITE(2104, 449, 70, 95, "adamantite"),
    you don't need the last parameter. enum.value.toString() will return what you're looking for.
    How would I loop through object types from my class is what I'm wondering. Also won't be on my computer until Monday does the value.toString() output it in lowercase? If so thanks that's useful to know.
    Reply With Quote  
     

  6. #6  
    SERGEANT OF THE MASTER SERGEANTS MOST IMPORTANT PERSON OF EXTREME SERGEANTS TO THE MAX!

    cube's Avatar
    Join Date
    Jun 2007
    Posts
    8,871
    Thanks given
    1,854
    Thanks received
    4,745
    Rep Power
    5000
    Quote Originally Posted by Bob the Cat View Post
    How would I loop through object types from my class is what I'm wondering. Also won't be on my computer until Monday does the value.toString() output it in lowercase? If so thanks that's useful to know.
    OreData.values() returns an array you can loop

    Attached image

    Reply With Quote  
     

  7. #7  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Quote Originally Posted by Bob the Cat View Post
    How would I loop through object types from my class is what I'm wondering. Also won't be on my computer until Monday does the value.toString() output it in lowercase? If so thanks that's useful to know.
    for(Enum enum : Enum.values()) {
    if(enum.id == input) {
    return enum;
    }
    }

    or use a lambada to filter the results through stream.filter.findfirst

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 5
    Last Post: 05-09-2009, 11:06 PM
  2. Need help With something easy!
    By qizdipin in forum Help
    Replies: 3
    Last Post: 04-27-2009, 01:45 AM
  3. Replies: 4
    Last Post: 04-09-2009, 12:19 AM
  4. [508] i need help with something
    By Gluon in forum Configuration
    Replies: 7
    Last Post: 01-04-2009, 08:32 PM
  5. i need help with something...
    By Dragonking in forum Website Development
    Replies: 0
    Last Post: 12-06-2008, 09:28 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •