Thread: [PI] Adding Food

Results 1 to 9 of 9
  1. #1 [PI] Adding Food 
    Registered Member
    Join Date
    Jul 2014
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    I need help adding food to my server and im just wondering how you do it ?
    I went to the food.java and copied this

    Code:
    		MANTA(391,22,"Manta Ray"),
    and pasted it again and changed everything to this.

    Code:
    		CHOCICE(6794,25,"Choc-Ice Bar");
    I thought it would work but it ended up with errors like this

    Code:
    src\server\model\players\Food.java:28: error: invalid method declaration; return
     type required
                    CHOCICE(6794,25,"Choc-Ice Bar");
                    ^
    src\server\model\players\Food.java:28: error: illegal start of type
                    CHOCICE(6794,25,"Choc-Ice Bar");
                            ^
    src\server\model\players\Food.java:28: error: illegal start of type
                    CHOCICE(6794,25,"Choc-Ice Bar");
                                 ^
    src\server\model\players\Food.java:28: error: illegal start of type
                    CHOCICE(6794,25,"Choc-Ice Bar");
                                    ^
    4 errors
    Press any key to continue . . .
    Reply With Quote  
     

  2. #2  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    post your whole enum of food please
    Reply With Quote  
     

  3. #3  
    Registered Member Pseudo's Avatar
    Join Date
    Jan 2014
    Posts
    227
    Thanks given
    31
    Thanks received
    43
    Rep Power
    37
    Quote Originally Posted by Nighel View Post
    post your whole enum of food please
    This. Simply adding it as another Enum Constant shouldn't have caused this.
    Reply With Quote  
     

  4. #4  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    Quote Originally Posted by Pseudo_ View Post
    This. Simply adding it as another Enum Constant shouldn't have caused this.
    I know but its hard to tell what he did wrong with what he just posted
    Reply With Quote  
     

  5. #5  
    Registered Member Pseudo's Avatar
    Join Date
    Jan 2014
    Posts
    227
    Thanks given
    31
    Thanks received
    43
    Rep Power
    37
    Quote Originally Posted by Nighel View Post
    I know but its hard to tell what he did wrong with what he just posted
    I know, my post was agreeing with what you said sir.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jul 2014
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Code:
     package server.model.players;
    
    import java.util.HashMap;
    
    /**
     * @author Sanity
     */
    
    public class Food {
    	
    	
    	private Client c;
    	
    	public Food (Client c) {
    		this.c = c;	
    	}
    	public static enum FoodToEat {		
    		MANTA(391,22,"Manta Ray"),
    		SHARK(385,20,"Shark"),
    		LOBSTER(379,12,"Lobster"),
    		TROUT(333,7,"Trout"),
    		SALMON(329,9,"Salmon"),
    		SWORDFISH(373,14,"Swordfish"),
    		TUNA(361,10,"Tuna"),
    		MONKFISH(7946,16,"Monkfish"),
    		SEA_TURTLE(397,22,"Sea Turtle"),
    		TUNA_POTATO(7060,22,"Tuna Potato");
    		
    		
    		private int id; private int heal; private String name;
    		
    		private FoodToEat(int id, int heal, String name) {
    			this.id = id;
    			this.heal = heal;
    			this.name = name;		
    		}
    		
    		public int getId() {
    			return id;
    		}
    
    		public int getHeal() {
    			return heal;
    		}
    		
    		public String getName() {
    			return name;
    		}
    		public static HashMap <Integer,FoodToEat> food = new HashMap<Integer,FoodToEat>();
    		
    		public static FoodToEat forId(int id) {
    			return food.get(id);
    		}
    		
    		static {
    		for (FoodToEat f : FoodToEat.values())
    			food.put(f.getId(), f);
    		}
    	}
    	
    	public void eat(int id, int slot) {
    		if (c.duelRule[6]) {
    			c.sendMessage("You may not eat in this duel.");
    			return;
    		}
    		if (System.currentTimeMillis() - c.foodDelay >= 1500 && c.playerLevel[3] > 0) {
    			c.getCombat().resetPlayerAttack();
    			c.attackTimer += 2;
    			c.startAnimation(829);
    			c.getItems().deleteItem(id,slot,1);
    			FoodToEat f = FoodToEat.food.get(id);
    			if (c.playerLevel[3] < c.getLevelForXP(c.playerXP[3])) {
    				c.playerLevel[3] += f.getHeal();
    				if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
    					c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
    			}
    			c.foodDelay = System.currentTimeMillis();
    			c.getPA().refreshSkill(3);
    			c.sendMessage("You eat the " + f.getName() + ".");
    		}		
    	}
    
    	
    	public boolean isFood(int id) {
    		return FoodToEat.food.containsKey(id);
    	}	
    	
    
    }
    Last edited by Fortune-X; 07-29-2014 at 06:52 PM. Reason: Typo
    Reply With Quote  
     

  7. #7  
    true

    DerekH's Avatar
    Join Date
    Dec 2011
    Age
    19
    Posts
    1,183
    Thanks given
    590
    Thanks received
    261
    Rep Power
    164
    Code:
    public static enum FoodToEat {		
    		MANTA(391,22,"Manta Ray"),
    		SHARK(385,20,"Shark"),
    		LOBSTER(379,12,"Lobster"),
    		TROUT(333,7,"Trout"),
    		SALMON(329,9,"Salmon"),
    		SWORDFISH(373,14,"Swordfish"),
    		TUNA(361,10,"Tuna"),
    		MONKFISH(7946,16,"Monkfish"),
    		SEA_TURTLE(397,22,"Sea Turtle"),
                    DICK_SNAPPERS(itemid,hphealed,"DICKSNAPPERS"),
    		TUNA_POTATO(7060,22,"Tuna Potato");
    Reply With Quote  
     

  8. #8  
    true

    DerekH's Avatar
    Join Date
    Dec 2011
    Age
    19
    Posts
    1,183
    Thanks given
    590
    Thanks received
    261
    Rep Power
    164
    Code:
    public static enum FoodToEat {		
    		MANTA(391,22,"Manta Ray"),
    		SHARK(385,20,"Shark"),
    		LOBSTER(379,12,"Lobster"),
    		TROUT(333,7,"Trout"),
    		SALMON(329,9,"Salmon"),
    		SWORDFISH(373,14,"Swordfish"),
    		TUNA(361,10,"Tuna"),
    		MONKFISH(7946,16,"Monkfish"),
    		SEA_TURTLE(397,22,"Sea Turtle"),
                    NEW_FOOD(itemid,hphealed,"name"),
    		TUNA_POTATO(7060,22,"Tuna Potato");
    Reply With Quote  
     

  9. #9  
    Registered Member Verisimilitude's Avatar
    Join Date
    Mar 2012
    Age
    26
    Posts
    487
    Thanks given
    45
    Thanks received
    17
    Rep Power
    0
    Quote Originally Posted by Fortune-X View Post
    I need help adding food to my server and im just wondering how you do it ?
    I went to the food.java and copied this

    Code:
    		MANTA(391,22,"Manta Ray"),
    and pasted it again and changed everything to this.

    Code:
    		CHOCICE(6794,25,"Choc-Ice Bar");
    I thought it would work but it ended up with errors like this

    Code:
    src\server\model\players\Food.java:28: error: invalid method declaration; return
     type required
                    CHOCICE(6794,25,"Choc-Ice Bar");
                    ^
    src\server\model\players\Food.java:28: error: illegal start of type
                    CHOCICE(6794,25,"Choc-Ice Bar");
                            ^
    src\server\model\players\Food.java:28: error: illegal start of type
                    CHOCICE(6794,25,"Choc-Ice Bar");
                                 ^
    src\server\model\players\Food.java:28: error: illegal start of type
                    CHOCICE(6794,25,"Choc-Ice Bar");
                                    ^
    4 errors
    Press any key to continue . . .
    Code:
     Bro you put the ->>> ; <<<- only after all the food is being added like
    Code:
         	SALMON(329, 9, "Salmon"), <<< the , is to tell there's going to be another food code being added
    		TUNA(361, 10, "Tuna"),
    			LOBSTER(379, 12, "Lobster"),
    				CHOCOLATE_CAKE(1897, 13, "Chocolate Cake"),
    				BASS(365, 13, "Bass"),
    			SWORDFISH(373, 14, "Swordfish"),
    		PLAIN_PIZZA(2289, 14, "Plain pizza"); <<< the ; is always at the end to close it
    [spoil][/spoil]
    Code:
    [Today 05:35 AM] Verisimilitude: My new siggy
    [Today 05:34 AM] Verisimilitude: Ikr
    [Today 05:34 AM] a Kitty: 'there is litteraly nothing i can do to reach him, so i will just stand here and accept my fate'

    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. [PI]Adding Dragon Claws Client Sided[PI]
    By iitzTyson in forum Tutorials
    Replies: 78
    Last Post: 09-06-2015, 08:30 PM
  2. [PI]Adding Consumable Food Parts
    By Myuria in forum Tutorials
    Replies: 10
    Last Post: 08-27-2012, 01:26 PM
  3. Replies: 8
    Last Post: 06-19-2010, 08:56 AM
  4. [PI] adding 474 models
    By 'Rhys in forum Help
    Replies: 4
    Last Post: 05-29-2010, 11:39 PM
  5. [508] Adding Food
    By hadesflames in forum Tutorials
    Replies: 19
    Last Post: 11-11-2008, 03:16 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
  •