Thread: Cooking(hyperion/rs2-server) small problem

Results 1 to 8 of 8
  1. #1 Cooking(hyperion/rs2-server) small problem 
    Registered Member Andrew's Avatar
    Join Date
    Nov 2008
    Posts
    2,890
    Thanks given
    612
    Thanks received
    207
    Rep Power
    551
    alright currently the new problem is this, when i click on the interface button i get disconnected, here is my buttons code, if i just use the shrimp on the stove with just 1 in the inventory it works, but when i click the button nothing occurs

    Code:
    	case 10:
    						if(obj.getDefinition().getName().equalsIgnoreCase("Range")) {
    							Food food = Food.forId(item.getId());
    							if(food != null) {
    								if(player.getInventory().getCount(food.getRaw()) > 1) {
    									player.getActionSender().sendInterfaceModel(309, 2, 130, food.getRaw());
    									player.getActionSender().sendString(309, 6, "<br><br><br><br>" + ItemDefinition.forId(food.getRaw()).getName());
    									player.getActionSender().sendChatboxInterface(309);
    									player.setInterfaceAttribute("cook_type", food);
    player.setInterfaceAttribute("cook_index", food.getIndex());	
    									return;
    									
    								} else {
    									player.getActionQueue().addAction(new CookingAction(player, 1, food));					
    						}
    						return;
    							}
    					}
    						break;



    Code:
    if(player.getInterfaceAttribute("cook_index") != null && player.getInterfaceAttribute("cook_type") != null) {
    					int productionCount = -1;
    					switch(childId) {
    					case 6:
    						productionCount = 1;
    						break;
    					case 5:
    						productionCount = 5;
    						break;
    					case 4:
    						player.getInterfaceState().openEnterAmountInterface(309, -1, -1);
    						break;
    					case 3:
    						productionCount = 28;
    						break;
    					}
    					if(productionCount != -1) {
    						player.getInterfaceAttribute("cook_type");
    						player.getActionQueue().addAction(new CookingAction(player, productionCount, Food.forId((Integer) player.getInterfaceAttribute("cook_index"))));
    							
    						player.getActionSender().removeChatboxInterface();
    					}
    				}

    and the class

    Code:
    package org.rs2server.rs2.model.skills;
    
    import java.util.HashMap;
    import java.util.Map;
    import java.security.SecureRandom;
    import org.rs2server.rs2.action.impl.ProductionAction;
    import org.rs2server.rs2.model.Animation;
    import org.rs2server.rs2.model.Graphic;
    import org.rs2server.rs2.model.Item;
    import org.rs2server.rs2.model.Mob;
    import org.rs2server.rs2.model.Skills;
    
    
    
    public class CookingAction extends ProductionAction {
    	
    	private final SecureRandom cookingRandom = new SecureRandom();
    
    	/**
    	 * The amount of items to produce.
    	 */
    	private int productionCount;
    	
    
    	/**
    	 * The food we are cooking
    	 */
    	private Food food;
    	
    	
    	public CookingAction(Mob mob, int productionCount, Food food) {
    		super(mob);
    		this.productionCount = productionCount;
    		this.food = food;
    	}
    
    	/**
    	 * Represents types of cooking food.
    	 * 
    	 * @author Linux
    	 * 
    	 */
    	public enum Food {
    
    		SHRIMP(1, 317, 315, 7954, 1, 34, 300);
    		
    		
    		
    		private int index;
    
    		/**
    		 * The raw item id
    		 */
    		private int raw;
    
    		/**
    		 * The cooked item id
    		 */
    		private int cooked;
    
    		/**
    		 * The burnt item id
    		 */
    		private int burnt;
    
    		/**
    		 * The required level
    		 */
    		private int level;
    
    		/**
    		 * The level once you stop burning
    		 */
    		private int bestLevel;
    
    		/**
    		 * The experience earned
    		 */
    		private final double exp;
    
    		/**
    		 * Creates a new cookable food
    		 * 
    		 * @param raw
    		 *            The raw item id
    		 * @param cooked
    		 *            The cooked item id
    		 * @param burnt
    		 *            The burnt item id
    		 * @param level
    		 *            The required level
    		 * @param bestLevel
    		 *            The level to stop burning
    		 * @param exp
    		 *            The experience earned.
    		 */
    		private Food(int index, int raw, int cooked, int burnt, int level, int bestLevel,
    				double exp) {
    			this.index = index;
    			this.raw = raw;
    			this.cooked = cooked;
    			this.burnt = burnt;
    			this.level = level;
    			this.bestLevel = bestLevel;
    			this.exp = exp;
    		}
    
    		/**
    		 * A map of object ids to foods.
    		 */
    		private static Map<Integer, Food> foods = new HashMap<>();
    
    		/**
    		 * Gets a food by an object id.
    		 * 
    		 * @param object
    		 *            The object id.
    		 * @return The food, or <code>null</code> if the object is not a food.
    		 */
    		public static Food forId(int object) {
    			return foods.get(object);
    		}
    
    		/**
    		 * Populates the tree map.
    		 */
    		static {
    			for (Food food : Food.values()) {
    				foods.put(food.raw, food);
    			}
    		}
    
    		/**
    		 * Gets the raw item id
    		 * 
    		 * @return The item id
    		 */
    		public int getRaw() {
    			return raw;
    		}
    		public int getIndex() {
    			return index;
    		}
    
    		/**
    		 * Gets the cooked item id
    		 * 
    		 * @return The item id
    		 */
    		public int getCooked() {
    			return cooked;
    		}
    
    		/**
    		 * Gets the burnt item id
    		 * 
    		 * @return The item id
    		 */
    		public int getBurnt() {
    			return burnt;
    		}
    
    		/**
    		 * Gets the required level
    		 * 
    		 * @return The level
    		 */
    		public int getLevel() {
    			return level;
    		}
    
    		/**
    		 * Gets the best level
    		 * 
    		 * @return The level
    		 */
    		public int getBestLevel() {
    			return bestLevel;
    		}
    
    		/**
    		 * Gets the experience
    		 * 
    		 * @return The experience
    		 */
    		public double getExp() {
    			return exp;
    		}
    	
    	}
    	
    	@Override
    	public boolean canProduce() {
    		return true;
    	}
    
    	@Override
    	public Animation getAnimation() {
    		return Animation.create(1248);
    	}
    
    	@Override
    	public Item[] getConsumedItems() {
    		return new Item[] { new Item(food.getRaw()) };
    	}
    
    	@Override
    	public int getCycleCount() {
    		return 3;
    	}
    
    	@Override
    	public double getExperience() {
    		return food.getExp();
    	}
    
    	@Override
    	public Graphic getGraphic() {
    		return null;
    	}
    
    	@Override
    	public String getLevelTooLowMessage() {
    		return "You need a Cooking level of " + getRequiredLevel() + " to cook this.";
    	}
    
    	@Override
    	public int getProductionCount() {
    		return productionCount;
    	}
    
    	@Override
    	public int getRequiredLevel() {
    		return food.getLevel();
    	}
    
    
    
    	@Override
    	public Item[] getRewards() {
    		//return new Item[] { new Item(food.getItem()[foodIndex])};
    		final double burnBonus = 3.0;
    		double burn_chance = 55.0 - burnBonus;
    		final double lev_needed = food.getLevel();
    		final double burn_stop = food.getBestLevel();
    		final double multi_a = burn_stop - lev_needed;
    		final double burn_dec = burn_chance / multi_a;
    		final double multi_b = Skills.COOKING - lev_needed;
    		burn_chance -= multi_b * burn_dec;
    		final double randNum = cookingRandom.nextDouble() * 100.0;
    		if (burn_chance <= randNum) {
    			return new Item[] { new Item(food.getCooked())};
    		} else {
    			return new Item[] { new Item(food.getBurnt())};
    		}
    	}
    
    	@Override
    	public int getSkill() {
    		return Skills.COOKING;
    	}
    
    	@Override
    	public String getSuccessfulProductionMessage() {
    		return "You successfully cook the food.";
    	}
    		
    }

    heres the error

    Code:
    SEVERE: Exception handling packet.
    java.lang.ClassCastException: org.rs2server.rs2.model.skills.CookingAction$Food cannot be cast to java.lang.Integer
    	at org.rs2server.rs2.packet.CloseInterfacePacketHandler.handle(CloseInterfacePacketHandler.java:309)
    	at org.rs2server.rs2.net.PacketManager.handle(PacketManager.java:73)
    	at org.rs2server.rs2.task.impl.SessionMessageTask.execute(SessionMessageTask.java:39)
    	at org.rs2server.rs2.GameEngine$1.run(GameEngine.java:105)
    	at org.rs2server.rs2.GameEngine$5.run(GameEngine.java:178)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    	at java.util.concurrent.FutureTask.run(Unknown Source)
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Reply With Quote  
     

  2. #2  
    Registered Member
    vovik ukr's Avatar
    Join Date
    Aug 2010
    Posts
    1,240
    Thanks given
    136
    Thanks received
    187
    Rep Power
    278
    the case id is supposed to be the object id of the range
    Reply With Quote  
     

  3. #3  
    CorruptionPVP CODER
    Kronos's Avatar
    Join Date
    Aug 2011
    Posts
    850
    Thanks given
    148
    Thanks received
    32
    Rep Power
    128
    Try what vovik ukr said, if it does not work go on the link below
    http://www.rune-server.org/runescape...n-cooking.html
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Registered Member
    vovik ukr's Avatar
    Join Date
    Aug 2010
    Posts
    1,240
    Thanks given
    136
    Thanks received
    187
    Rep Power
    278
    just add this under public void execute() {


    Code:
    						if(obj.getDefinition().getName().equalsIgnoreCase("Range")) {
    							Food food = Food.forId(item.getId());
    							if(food != null) {
    								if(player.getInventory().getCount(food.getRaw()) > 1) {
    									player.getActionSender().sendInterfaceModel(307, 2, 130, food.getRaw());
    									player.getActionSender().sendString(307, 6, "<br><br><br><br>" + ItemDefinition.forId(food.getRaw()).getName());
    									player.getActionSender().sendChatboxInterface(307);
    									player.setInterfaceAttribute("cook_type", food);
    									return;
    									
    								} else {
    									player.getActionQueue().addAction(new CookingAction(player, 1, food));					
    						}
    						return;
    							}
    					}
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    CorruptionPVP CODER
    Kronos's Avatar
    Join Date
    Aug 2011
    Posts
    850
    Thanks given
    148
    Thanks received
    32
    Rep Power
    128
    Simple as that ^
    Reply With Quote  
     

  8. #6  
    Registered Member Andrew's Avatar
    Join Date
    Nov 2008
    Posts
    2,890
    Thanks given
    612
    Thanks received
    207
    Rep Power
    551
    Quote Originally Posted by Kronos View Post
    Try what vovik ukr said, if it does not work go on the link below
    http://www.rune-server.org/runescape...n-cooking.html
    im actually using that enum + formula, and that formula seems wrong because im burning shrimp with 99 cooking. lol
    Reply With Quote  
     

  9. #7  
    Registered Member Andrew's Avatar
    Join Date
    Nov 2008
    Posts
    2,890
    Thanks given
    612
    Thanks received
    207
    Rep Power
    551
    numppp with the new problem
    Reply With Quote  
     

  10. #8  
    Registered Member Andrew's Avatar
    Join Date
    Nov 2008
    Posts
    2,890
    Thanks given
    612
    Thanks received
    207
    Rep Power
    551
    upppppp
    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: 3
    Last Post: 07-26-2013, 12:33 AM
  2. Hyperion (Rs2-Server) "loading please wait"
    By RIPINPIECE 2PAC ND BIGGIE in forum Help
    Replies: 1
    Last Post: 03-11-2013, 02:17 AM
  3. Hyperion rs2-server problem
    By idc123 in forum Help
    Replies: 10
    Last Post: 07-31-2012, 02:54 PM
  4. [hyperion] rs2-server bugs
    By !!A!! in forum Requests
    Replies: 0
    Last Post: 05-23-2012, 05:38 PM
  5. Hyperion Rs2-server 474 DFS definition
    By Redefined in forum Help
    Replies: 1
    Last Post: 04-21-2012, 05:04 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
  •