Thread: [718] ItemonItem Issue

Results 1 to 8 of 8
  1. #1 [718] ItemonItem Issue 
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    Hey guys, there has been another similar post to this but I think people look at how many replies it has and continue on with their day. Since I have yet to post a thread I assume it is fine with me doing so, as I plan on hopefully expanding the issue so that the next person searching the web will be able to find a solution.

    I am using the Eriewin II source found here.

    The issue is that if you attempt to use the chisel on a gem, or simply click "craft" on a gem it does nothing. In the last thread it was simplified down to the stream is being read first, then calling the method, so the stream was empty and the method couldnt assign the variables from the stream (Thanks Arham for figuring this bit out).

    This is where the previous thread stopped. Sadly, I am a novice coder and do not have the slightest clue where to start from there. I have done the "silly" things such as rearranging code etc, but have failed to have any success in figuring this out.

    If someone could edge me in the right direction, I would love to be able to figure out the workings of this while solving the situation overall.

    Here are the codes:

    IventoryOptionsHandler.java:
    Code:
    			//Gem Cutting
    			else if (contains(1755, Gem.LIMESTONE.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.LIMESTONE);
    			else if (contains(1755, Gem.OPAL.getUncut(), itemUsed, usedWith)) {
    				GemCutting.cut(player, Gem.OPAL);
    				player.getPackets().sendGameMessage("Testing");
    			}
    			else if (contains(1755, Gem.JADE.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.JADE);
    			else if (contains(1755, Gem.RED_TOPAZ.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.RED_TOPAZ);
    			else if (contains(1755, Gem.SAPPHIRE.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.SAPPHIRE);
    			else if (contains(1755, Gem.EMERALD.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.EMERALD);
    			else if (contains(1755, Gem.RUBY.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.RUBY);
    			else if (contains(1755, Gem.DIAMOND.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.DIAMOND);
    			else if (contains(1755, Gem.DRAGONSTONE.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.DRAGONSTONE);
    			else if (contains(1755, Gem.ONYX.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.ONYX);
    			//Bolt Tip Making
    			else if (contains(1755, BoltTips.OPAL.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.OPAL);
    			else if (contains(1755, BoltTips.JADE.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.JADE);
    			else if (contains(1755, BoltTips.RED_TOPAZ.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.RED_TOPAZ);
    			else if (contains(1755, BoltTips.SAPPHIRE.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.SAPPHIRE);
    			else if (contains(1755, BoltTips.EMERALD.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.EMERALD);
    			else if (contains(1755, BoltTips.RUBY.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.RUBY);
    			else if (contains(1755, BoltTips.DIAMOND.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.DIAMOND);
    			else if (contains(1755, BoltTips.DRAGONSTONE.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.DRAGONSTONE);
    			else if (contains(1755, BoltTips.ONYX.getGemName(), itemUsed, usedWith))
    				BoltTipFletching.boltFletch(player, BoltTips.ONYX);
    GemCutting.java
    Code:
    package com.rs.game.player.actions;
    
    import com.rs.cache.loaders.ItemDefinitions;
    import com.rs.game.Animation;
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    
    public class GemCutting extends Action {
    
    	/**
    	 * Enum for gems
    	 * 
    	 * @author Raghav
    	 * 
    	 */
    	public enum Gem {
    		OPAL(1625, 1609, 15.0, 1, 886),
    
    		JADE(1627, 1611, 20, 13, 886),
    
    		RED_TOPAZ(1629, 1613, 25, 16, 887),
    
    		SAPPHIRE(1623, 1607, 50, 20, 888),
    
    		EMERALD(1621, 1605, 67, 27, 889),
    
    		RUBY(1619, 1603, 85, 34, 887),
    
    		DIAMOND(1617, 1601, 107.5, 43, 890),
    
    		DRAGONSTONE(1631, 1615, 137.5, 55, 885),
    
    		ONYX(6571, 6573, 167.5, 67, 2717),
    		
    		LIMESTONE(3211, 3420, 10, 12, 2717);
    
    		private double experience;
    		private int levelRequired;
    		private int uncut, cut;
    
    		private int emote;
    
    		private Gem(int uncut, int cut, double experience, int levelRequired,
    				int emote) {
    			this.uncut = uncut;
    			this.cut = cut;
    			this.experience = experience;
    			this.levelRequired = levelRequired;
    			this.emote = emote;
    		}
    
    		public int getLevelRequired() {
    			return levelRequired;
    		}
    
    		public double getExperience() {
    			return experience;
    		}
    
    		public int getUncut() {
    			return uncut;
    		}
    
    		public int getCut() {
    			return cut;
    		}
    
    		public int getEmote() {
    			return emote;
    		}
    
    	}
    
    	public static void cut(Player player, Gem gem) {
    		if (player.getInventory().getItems()
    				.getNumberOf(new Item(gem.getUncut(), 1)) <= 1) // contains just
    			// 1 lets start
    			player.getActionManager().setAction(new GemCutting(gem, 1));
    		else
    			player.getDialogueManager().startDialogue("GemCuttingD", gem);
    	}
    
    	private Gem gem;
    	private int quantity;
    
    	public GemCutting(Gem gem, int quantity) {
    		this.gem = gem;
    		this.quantity = quantity;
    	}
    
    	public boolean checkAll(Player player) {
    		if (player.getSkills().getLevel(Skills.CRAFTING) < gem
    				.getLevelRequired()) {
    			player.getDialogueManager().startDialogue(
    					"SimpleMessage",
    					"You need a crafting level of " + gem.getLevelRequired()
    					+ " to cut that gem.");
    			return false;
    		}
    		if (!player.getInventory().containsOneItem(gem.getUncut())) {
    			player.getDialogueManager().startDialogue(
    					"SimpleMessage",
    					"You don't have any "
    							+ ItemDefinitions
    							.getItemDefinitions(gem.getUncut())
    							.getName().toLowerCase() + " to cut.");
    			return false;
    		}
    		return true;
    	}
    
    	@Override
    	public boolean start(Player player) {
    		if (checkAll(player)) {
    			setActionDelay(player, 1);
    			player.setNextAnimation(new Animation(gem.getEmote()));
    			return true;
    		}
    		return false;
    	}
    
    	@Override
    	public boolean process(Player player) {
    		return checkAll(player);
    	}
    
    	@Override
    	public int processWithDelay(Player player) {
    		player.getInventory().deleteItem(gem.getUncut(), 1);
    		player.getInventory().addItem(gem.getCut(), 1);
    		//if (gem.getUncut() == 1617)
    			//player.cutDiamonds++;
    		//player.randomevent(player);
    		player.getSkills().addXp(Skills.CRAFTING, gem.getExperience());
    		player.getPackets().sendGameMessage(
    				"You cut the "
    						+ ItemDefinitions.getItemDefinitions(gem.getUncut())
    						.getName().toLowerCase() + ".", true);
    		quantity--;
    		if (quantity <= 0)
    			return -1;
    		player.setNextAnimation(new Animation(gem.getEmote())); // start the
    		// emote and add
    		// 2 delay
    		return 0;
    	}
    
    	@Override
    	public void stop(final Player player) {
    		setActionDelay(player, 3);
    	}
    }

    GemCuttingD.java
    Code:
    package com.rs.game.player.dialogues;
    
    import com.rs.game.player.actions.GemCutting;
    import com.rs.game.player.actions.GemCutting.Gem;
    import com.rs.game.player.content.SkillsDialogue;
    
    public class GemCuttingD extends Dialogue {
    
    	private Gem gem;
    
    	@Override
    	public void start() {
    		this.gem = (Gem) parameters[0];
    		SkillsDialogue
    				.sendSkillsDialogue(
    						player,
    						SkillsDialogue.CUT,
    						"Choose how many you wish to cut,<br>then click on the item to begin.",
    						player.getInventory().getItems()
    								.getNumberOf(gem.getUncut()),
    						new int[] { gem.getUncut() }, null);
    
    	}
    
    	@Override
    	public void run(int interfaceId, int componentId) {
    		player.getActionManager().setAction(
    				new GemCutting(gem, SkillsDialogue.getQuantity(player)));
    		end();
    	}
    
    	@Override
    	public void finish() {
    
    	}
    
    }
    Related post: [718] GemCutting/ItemonItem not working

    If you need something that I have left out please comment below, also I have done everything leading up to the point of Arham's comment so the tool belt thing is fully functional and I tried with it.
    Elite Lurker
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    I just noticed that in the checker I have nothing to do with crafting, but neither does the server I ripped this bit off of so I was momentarily confused.

    I did receive the message when I added the "testing" bit into the checker though.

    Code:
    		else if (item.getDefinitions().containsOption(0, "Craft") || item.getDefinitions().containsOption(0, "Fletch")) {
    		    if (player.getInventory().hasItem(946, 1)) {
    			Fletch fletch = Fletching.isFletching(item, new Item(946));
    			if (fletch != null) {
    			    player.getDialogueManager().startDialogue("FletchingD", fletch);
    			    return;
    			}
    		    } else if (player.getInventory().hasItem(1755, 1)) {
    			Fletch fletch = Fletching.isFletching(item, new Item(1755));
    			if (fletch != null) {
    			    player.getDialogueManager().startDialogue("FletchingD", fletch);
    			    return;
    			}
    		    } else
    			player.getDialogueManager().startDialogue("ItemMessage", "You need a knife or chisle to complete the action.", 946);
    		}
    Also just noticed how dumb I was for misunderstanding your question, I did not receive the message for the one below the opal cutting.
    Elite Lurker
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    Again sorry for misunderstanding, heres the contains check method..

    Code:
    	public static boolean contains(int id1, int id2, Item... items) {
    		boolean containsId1 = false;
    		boolean containsId2 = false;
    		for (Item item : items) {
    			if (item.getId() == id1)
    				containsId1 = true;
    			else if (item.getId() == id2)
    				containsId2 = true;
    		}
    		return containsId1 && containsId2;
    	}
    Elite Lurker
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    Sorry if I seem like a complete idiot, but by doing that do you mean something or this sort? As I can't just simply add it without an if statement.

    Code:
    			if (player.getInventory().hasItem(1755, 1))
    				player.getPackets().sendGameMessage("Testing this shit to see if its ever going to fucking work.");
    			//Gem Cutting
    			else if (contains(1755, Gem.LIMESTONE.getUncut(), itemUsed, usedWith))
    				GemCutting.cut(player, Gem.LIMESTONE);
    Elite Lurker
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    No message when click "craft" or using the chisel on the gem.
    Elite Lurker
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    Edit: nevermind some further looking in revealed its just my ItemonItem handler, will update once I figure out the craziness..
    Elite Lurker
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    Update: Appears as if everything but my itemonitem method works. Other item options are fully functional as well. I am officially clueless to where the problem lies as it is solely in the itemonitem or container method, which both look fine.

    Edit: Tracked down the different contains methods, all seem to be coded correctly. Even looked in WorldPackets and ItemDefinitions just incase there was something crazy going on but no fix so far. Anyone care to suggest further spots to check?
    Elite Lurker
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Aug 2007
    Posts
    248
    Thanks given
    28
    Thanks received
    25
    Rep Power
    5
    Still having issues with this, any further advice is greatly appreciated.
    Elite Lurker
    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. 718 - run issue
    By RS Wiki in forum Help
    Replies: 7
    Last Post: 01-11-2013, 08:39 PM
  2. [718] Map Issues
    By arcen in forum Help
    Replies: 1
    Last Post: 01-08-2013, 07:19 PM
  3. 718 Client Issues, Please Read.
    By simplelyons in forum Help
    Replies: 0
    Last Post: 10-27-2012, 04:59 AM
  4. 718 Matrix Issues.
    By simplelyons in forum Help
    Replies: 7
    Last Post: 10-21-2012, 10:53 AM
  5. [718] Webclient Issues.
    By Dat Guy in forum Help
    Replies: 2
    Last Post: 08-11-2012, 03:02 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
  •