Thread: Mining Pickaxes (Fixed)

Results 1 to 9 of 9
  1. #1 Mining Pickaxes (Fixed) 
    Registered Member
    Stimulant's Avatar
    Join Date
    Jan 2013
    Age
    22
    Posts
    1,393
    Thanks given
    197
    Thanks received
    168
    Rep Power
    515
    Hi, been rewritting mining but I am stuck for the pickaxes part, here the codes with the explications:

    The enum of course with the pickaxes informations:
    Code:
    public enum Pickaxes {
    
    		BRONZE_PICKAXE(1265, 625, 1, 1),
    		IRON_PICKAXE(1267, 626, 2, 1),
    		STEEL_PICKAXE(1269, 627, 3, 6),
    		MITHRIL_PICKAXE(1273, 629, 5, 21),
    		ADAMANT_PICKAXE(1271, 628, 7, 31),
    		RUNE_PICKAXE(1275, 624, 10, 41),
    		DRAGON_PICKAXE(15259, 12189, 13, 61); // Animation may be incorrect.
    		
    		private int pickaxeId, animationId, pickaxeTime, level;
    		
    		private Pickaxes(int pickaxeId, int animationId, int pickaxeTime, int level) {
    			this.pickaxeId = pickaxeId;
    			this.animationId = animationId;
    			this.pickaxeTime = pickaxeTime;
    			this.level = level;
    		}
    		
    		public int getPickaxeId() {
    			return pickaxeId;
    		}
    		
    		public int getAnimationId() {
    			return animationId;
    		}
    		
    		public int getPickaxeTime() {
    			return pickaxeTime;
    		}
    		
    		public int getLevel() {
    			return level;
    		}
    	}
    The check:
    Code:
    pickaxe = getPickaxe(player);
    		if (pickaxe == null) {
    			player.getDialogueManager().startDialogue("SimpleMessage", "You need a pickaxe to mine this rock. You do not have a pickaxe", "which you have the Mining level to use.");
    			return false;
    		}
    Here what I'm trying to do is to make it check if the player has it in the inventory or in the weapon slot also to check the best pickaxe you have but it doesn't work (added in red what I think is wrong).
    Code:
    public static Pickaxes getPickaxe(Player player) {
    		for (int i = Pickaxes.values().length - 1; i >= 7; i--) {
    			Pickaxes pickaxe = Pickaxes.values()[i];
    			if (player.getInventory().containsItemToolBelt(1265) || player.getEquipment().getWeaponId() == pickaxe.getPickaxeId()) {
    				if (player.getSkills().getLevel(Skills.MINING) < pickaxe.getLevel()) {
    					return pickaxe;
    				}
    			}
    		}
    		return null;
    - Thanks.
    Reply With Quote  
     

  2. #2  
    Wut can u say when theres nothin to tell

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    20
    Posts
    1,528
    Thanks given
    641
    Thanks received
    385
    Rep Power
    950
    Code:
    public enum Pickaxes {
    
    		BRONZE_PICKAXE(1265, 625, 1, 1),
    		IRON_PICKAXE(1267, 626, 2, 1),
    		STEEL_PICKAXE(1269, 627, 3, 6),
    		MITHRIL_PICKAXE(1273, 629, 5, 21),
    		ADAMANT_PICKAXE(1271, 628, 7, 31),
    		RUNE_PICKAXE(1275, 624, 10, 41),
    		DRAGON_PICKAXE(15259, 12189, 13, 61); // Animation may be incorrect.
    		
    		private int pickaxeId, animationId, pickaxeTime, level;
    		
    		private Pickaxes(int pickaxeId, int animationId, int pickaxeTime, int level) {
    			this.pickaxeId = pickaxeId;
    			this.animationId = animationId;
    			this.pickaxeTime = pickaxeTime;
    			this.level = level;
    		}
    
                    //cache		
                    public static final EnumSet<Pickaxes> PICKAXES = EnumSet.allOf(Pickaxes.class);
    
    		public int getPickaxeId() {
    			return pickaxeId;
    		}
    		
    		public int getAnimationId() {
    			return animationId;
    		}
    		
    		public int getPickaxeTime() {
    			return pickaxeTime;
    		}
    		
    		public int getLevel() {
    			return level;
    		}
    	}
    Code:
    public static Pickaxes getPickaxe(Player player) {
    		for (int i = Pickaxes.PICKAXES.size() - 1; i < 7; i--) {
    			Pickaxes pickaxe = Pickaxes.values()[i];
    			if (player.getInventory().containsItemToolBelt(1265) || player.getEquipment().getWeaponId() == pickaxe.getPickaxeId()) {
    				if (player.getSkills().getLevel(Skills.MINING) < pickaxe.getLevel()) {
    					return pickaxe;
    				}
    			}
    		}
    		return null;
    I believe this should work, if not, change size() -1 to size().
    Also, cached values for you as repeatedly calling #values is just a waste of memory and performance.




    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Textures developer

    Kris's Avatar
    Join Date
    Jun 2016
    Age
    22
    Posts
    3,445
    Thanks given
    595
    Thanks received
    2,101
    Discord
    Kris#1337
    Rep Power
    3179
    Lol.
    Code:
    for (int i = Pickaxes.values().length - 1; i >= 0; i--) {
    You just had your backwards loop wrong there mate.


    Edit: Oh and make your level check <= not just <.
    Spoiler for sig too large:

    [Only registered and activated users can see links. ]

    Discord: Kris#1337
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    Registered Member
    Stimulant's Avatar
    Join Date
    Jan 2013
    Age
    22
    Posts
    1,393
    Thanks given
    197
    Thanks received
    168
    Rep Power
    515
    Quote Originally Posted by Kris View Post
    Lol.
    Code:
    for (int i = Pickaxes.values().length - 1; i >= 0; i--) {
    You just had your backwards loop wrong there mate.


    Edit: Oh and make your level check <= not just <.
    It's now printing all pickaxes, before it was just the dragon one also it still says that I don't have the level required for the pickaxes.
    Reply With Quote  
     

  7. #5  
    Textures developer

    Kris's Avatar
    Join Date
    Jun 2016
    Age
    22
    Posts
    3,445
    Thanks given
    595
    Thanks received
    2,101
    Discord
    Kris#1337
    Rep Power
    3179
    Quote Originally Posted by Stimulant View Post
    It's now printing all pickaxes, before it was just the dragon one also it still says that I don't have the level required for the pickaxes.
    Maybe cus
    Code:
    if (player.getInventory().containsItemToolBelt(1265) || player.getEquipment().getWeaponId() == pickaxe.getPickaxeId()) {
    1265? lol.
    Spoiler for sig too large:

    [Only registered and activated users can see links. ]

    Discord: Kris#1337
    Reply With Quote  
     

  8. Thankful user:


  9. #6  
    Registered Member
    Stimulant's Avatar
    Join Date
    Jan 2013
    Age
    22
    Posts
    1,393
    Thanks given
    197
    Thanks received
    168
    Rep Power
    515
    Quote Originally Posted by Kris View Post
    Maybe cus
    Code:
    if (player.getInventory().containsItemToolBelt(1265) || player.getEquipment().getWeaponId() == pickaxe.getPickaxeId()) {
    1265? lol.
    1265 is the bronze pickaxe, I've put "pickaxe.getPickaxeId()" instead, when printing, it now checks the inv, weapon and toolbelt but still says that I don't have the level :thinking:

    Edit: Got it, it was ">= pickaxe.getLevel()".
    Reply With Quote  
     

  10. #7  
    Mug Club


    Join Date
    Jul 2011
    Age
    25
    Posts
    1,778
    Thanks given
    493
    Thanks received
    831
    Rep Power
    254
    Code:
            BRONZE(1265, 1, 625, 8),
    	BRONZE_G(20780, 1, 234, 8),
    	IRON(1267, 1, 626, 7),
    	IRON_G(20781, 1, 235, 7),
    	STEEL(1269, 6, 627, 6),
    	STEEL_G(20782, 6, 236, 6),
    	MITHRIL(1273, 21, 629, 5),
    	MITHRIL_G(20784, 21, 238, 5),
    	ADAMANT(1271, 31, 628, 4),
    	ADAMANT_G(20783, 31, 237, 4),
    	RUNE(1275, 41, 624, 3),
    	RUNE_G(20785, 41, 249, 3),
    	DRAGON(15259, 61, 12189, 3),
    	DRAGON_G(20786, 61, 250, 3),
    	INFERNO_ADZE(13661, 61, 10222, 3);
    	
    	private int itemId, level, ticks;
    	private Animation animation;
    	
    	private Pickaxe(int itemId, int level, int animId, int ticks) {
    		this.itemId = itemId;
    		this.level = level;
    		this.animation = new Animation(animId);
    		this.ticks = ticks;
    	}
    Real RS pickaxes have a tick speed that determines how fast the mining process rolls for success by the way. Dragon has a 25% chance to be 2 tick instead of 3 tick.
    Reply With Quote  
     

  11. Thankful user:


  12. #8  
    Registered Member
    Stimulant's Avatar
    Join Date
    Jan 2013
    Age
    22
    Posts
    1,393
    Thanks given
    197
    Thanks received
    168
    Rep Power
    515
    Quote Originally Posted by Makar View Post
    Code:
            BRONZE(1265, 1, 625, 8),
    	BRONZE_G(20780, 1, 234, 8),
    	IRON(1267, 1, 626, 7),
    	IRON_G(20781, 1, 235, 7),
    	STEEL(1269, 6, 627, 6),
    	STEEL_G(20782, 6, 236, 6),
    	MITHRIL(1273, 21, 629, 5),
    	MITHRIL_G(20784, 21, 238, 5),
    	ADAMANT(1271, 31, 628, 4),
    	ADAMANT_G(20783, 31, 237, 4),
    	RUNE(1275, 41, 624, 3),
    	RUNE_G(20785, 41, 249, 3),
    	DRAGON(15259, 61, 12189, 3),
    	DRAGON_G(20786, 61, 250, 3),
    	INFERNO_ADZE(13661, 61, 10222, 3);
    	
    	private int itemId, level, ticks;
    	private Animation animation;
    	
    	private Pickaxe(int itemId, int level, int animId, int ticks) {
    		this.itemId = itemId;
    		this.level = level;
    		this.animation = new Animation(animId);
    		this.ticks = ticks;
    	}
    Real RS pickaxes have a tick speed that determines how fast the mining process rolls for success by the way. Dragon has a 25% chance to be 2 tick instead of 3 tick.
    I was looking for this, couldn't find anything on the wiki, thanks
    Reply With Quote  
     

  13. #9  
    Mug Club


    Join Date
    Jul 2011
    Age
    25
    Posts
    1,778
    Thanks given
    493
    Thanks received
    831
    Rep Power
    254
    Quote Originally Posted by Stimulant View Post
    I was looking for this, couldn't find anything on the wiki, thanks
    Jmod twitters have more than the wiki in most cases unfortunately lol
    Reply With Quote  
     

  14. Thankful user:



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. [Pi] Explaining Mining PickAxes
    By - Valhalla - in forum Help
    Replies: 22
    Last Post: 06-07-2013, 11:19 PM
  2. Mining animation fix for PI/DPSK
    By Barinade in forum Help
    Replies: 11
    Last Post: 12-23-2010, 03:37 AM
  3. Delta mining glitch fix
    By Polaroid in forum Snippets
    Replies: 12
    Last Post: 02-17-2010, 07:22 PM
  4. Replies: 19
    Last Post: 01-02-2010, 11:59 PM
  5. Dirty fix for my Mining Tut.
    By ~Legend Rene in forum Tutorials
    Replies: 6
    Last Post: 10-03-2007, 09:00 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •