Thread: Smithing data enum

Page 4 of 4 FirstFirst ... 234
Results 31 to 34 of 34
  1. #31  
    Ex RuneScape Pioneer

    Join Date
    Jun 2008
    Posts
    3,540
    Thanks given
    457
    Thanks received
    1,259
    Rep Power
    1015
    Quote Originally Posted by Linus View Post
    Code:
    
    	public void showSmithInterface(int itemId) {
    		if(c == null)
    			return;
    				
    		c.getPA().sendFrame126(" ", 1132);
    		c.getPA().sendFrame126(" ", 1135);
    		c.getPA().sendFrame126(" ", 1096);
    		c.getPA().sendFrame126(" ", 1134);
    		c.getPA().sendFrame34(-1, 3, 1123, 0);
    		c.getPA().sendFrame34(-1, 4, 1123, 0);
        	
    	    for(SmithingInterfaceData b : SmithingInterfaceData.values()) {
    	        if(b.barId == itemId) {
    	        	String barColor = "@[email protected]";
    	        	String itemColor = "@[email protected]";
    	        	if(c.playerLevel[c.playerSmithing] >= b.requiredLevel) {
    	        		itemColor = "@[email protected]";
    	            	if(c.getItems().playerHasItem(b.barId, b.barsRequired)) {
    	            		barColor = "@[email protected]";
    	            	}
    	        	}
    	    		c.getPA().sendFrame126(barColor + ""+b.barsRequired+" Bars", b.barFrame);
    	    		c.getPA().sendFrame126(itemColor +""+b.name, b.nameFrame);
    	    		c.getPA().sendFrame34(b.itemId, b.itemSlot, b.itemFrame, b.amount);
    	        } else {
    	        	continue;
    	        }
    	    }
    		c.getPA().showInterface(994);
    	}
    For pi
    why just why

    but yeah this is incredibly inefficient. you should redo this with scu11's advise.

    Code:
    		player.getPacketSender().sendString(1112, fiveb + "5 Bars" + fiveb);
    		player.getPacketSender().sendString(1109, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1110, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1118, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1111, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1095, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1115, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1090, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1113, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1116, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1114, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1089, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(8428, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1124, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1125, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1126, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1127, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1128, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1129, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1130, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1131, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(13357, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(11459, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1101, GetForlvl(18, player) + "Plate Body" + GetForlvl(18, player));
    		player.getPacketSender().sendString(1099, GetForlvl(16, player) + "Plate Legs" + GetForlvl(16, player));
    		player.getPacketSender().sendString(1100, GetForlvl(16, player) + "Plate Skirt" + GetForlvl(16, player));
    		player.getPacketSender().sendString(1088, GetForlvl(14, player) + "2 Hand Sword" + GetForlvl(14, player));
    		player.getPacketSender().sendString(1105, GetForlvl(12, player) + "Kite Shield" + GetForlvl(12, player));
    		player.getPacketSender().sendString(1098, GetForlvl(11, player) + "Chain Body" + GetForlvl(11, player));
    		player.getPacketSender().sendString(1092, GetForlvl(10, player) + "Battle Axe" + GetForlvl(10, player));
    		player.getPacketSender().sendString(1083, GetForlvl(9, player) + "Warhammer" + GetForlvl(9, player));
    		player.getPacketSender().sendString(1104, GetForlvl(8, player) + "Square Shield" + GetForlvl(8, player));
    		player.getPacketSender().sendString(1103, GetForlvl(7, player) + "Full Helm" + GetForlvl(7, player));
    		player.getPacketSender().sendString(1106, GetForlvl(7, player) + "Throwing Knives" + GetForlvl(7, player));
    		player.getPacketSender().sendString(1086, GetForlvl(6, player) + "Long Sword" + GetForlvl(6, player));
    		player.getPacketSender().sendString(1087, GetForlvl(5, player) + "Scimitar" + GetForlvl(5, player));
    		player.getPacketSender().sendString(1108, GetForlvl(5, player) + "Arrowtips" + GetForlvl(5, player));
    		player.getPacketSender().sendString(1085, GetForlvl(4, player) + "Sword" + GetForlvl(4, player));
    		player.getPacketSender().sendString(1107, GetForlvl(4, player) + "Bolts" + GetForlvl(4, player));
    		player.getPacketSender().sendString(13358, GetForlvl(4, player) + "Nails" + GetForlvl(4, player));
    		player.getPacketSender().sendString(1102, GetForlvl(3, player) + "Medium Helm" + GetForlvl(3, player));
    		player.getPacketSender().sendString(1093, GetForlvl(2, player) + "Mace" + GetForlvl(2, player));
    		player.getPacketSender().sendString(1094, GetForlvl(1, player) + "Dagger" + GetForlvl(1, player));
    		player.getPacketSender().sendString(1091, GetForlvl(1, player) + "Hatchet" + GetForlvl(1, player));
    		player.getPacketSender().sendString(8429, GetForlvl(8, player) + "Claws" + GetForlvl(8, player));
    		player.getPacketSender().sendSmithingData(1205,0,1119,1);
    		player.getPacketSender().sendSmithingData(1351,0,1120,1);
    		player.getPacketSender().sendSmithingData(1103,0,1121,1);
    		player.getPacketSender().sendSmithingData(1139,0,1122,1);
    		player.getPacketSender().sendSmithingData(819,0,1123,10);
    		player.getPacketSender().sendSmithingData(1277,1,1119,1);
    		player.getPacketSender().sendSmithingData(1422,1,1120,1);
    		player.getPacketSender().sendSmithingData(1075,1,1121,1);
    		player.getPacketSender().sendSmithingData(1155,1,1122,1);
    		player.getPacketSender().sendSmithingData(39,1,1123,15);
    		player.getPacketSender().sendSmithingData(1321,2,1119,1);
    		player.getPacketSender().sendSmithingData(1337,2,1120,1);
    		player.getPacketSender().sendSmithingData(1087,2,1121,1);
    		player.getPacketSender().sendSmithingData(1173,2,1122,1);
    		player.getPacketSender().sendSmithingData(864,2,1123,5);
    		player.getPacketSender().sendSmithingData(1291,3,1119,1);
    		player.getPacketSender().sendSmithingData(1375,3,1120,1);
    		player.getPacketSender().sendSmithingData(1117,3,1121,1);
    		player.getPacketSender().sendSmithingData(1189,3,1122,1);
    		player.getPacketSender().sendSmithingData(1307,4,1119,1);
    		player.getPacketSender().sendSmithingData(4819,4,1122,15);
    		player.getPacketSender().sendSmithingData(3095,4,1120, 1);
    		player.getPacketSender().sendSmithingData(-1,3,1123, 1);
    		player.getPacketSender().sendString(1135, "");
    		player.getPacketSender().sendString(1134, "");
    		player.getPacketSender().sendString(11461, "");
    		player.getPacketSender().sendString(11459, "");
    		player.getPacketSender().sendString(1132, "");
    		player.getPacketSender().sendString(1096, "");
    thats a lot of packets being sent in 1 tick for just 1 person.
    Reply With Quote  
     

  2. #32  
    Textures developer

    Kris's Avatar
    Join Date
    Jun 2016
    Age
    21
    Posts
    3,416
    Thanks given
    569
    Thanks received
    2,071
    Rep Power
    2878
    Quote Originally Posted by nshusa View Post
    why just why

    but yeah this is incredibly inefficient. you should redo this with scu11's advise.

    Code:
    		player.getPacketSender().sendString(1112, fiveb + "5 Bars" + fiveb);
    		player.getPacketSender().sendString(1109, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1110, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1118, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1111, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1095, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1115, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1090, threeb + "3 Bars" + threeb);
    		player.getPacketSender().sendString(1113, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1116, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1114, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1089, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(8428, twob + "2 Bars" + twob);
    		player.getPacketSender().sendString(1124, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1125, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1126, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1127, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1128, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1129, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1130, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1131, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(13357, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(11459, oneb + "1 Bar" + oneb);
    		player.getPacketSender().sendString(1101, GetForlvl(18, player) + "Plate Body" + GetForlvl(18, player));
    		player.getPacketSender().sendString(1099, GetForlvl(16, player) + "Plate Legs" + GetForlvl(16, player));
    		player.getPacketSender().sendString(1100, GetForlvl(16, player) + "Plate Skirt" + GetForlvl(16, player));
    		player.getPacketSender().sendString(1088, GetForlvl(14, player) + "2 Hand Sword" + GetForlvl(14, player));
    		player.getPacketSender().sendString(1105, GetForlvl(12, player) + "Kite Shield" + GetForlvl(12, player));
    		player.getPacketSender().sendString(1098, GetForlvl(11, player) + "Chain Body" + GetForlvl(11, player));
    		player.getPacketSender().sendString(1092, GetForlvl(10, player) + "Battle Axe" + GetForlvl(10, player));
    		player.getPacketSender().sendString(1083, GetForlvl(9, player) + "Warhammer" + GetForlvl(9, player));
    		player.getPacketSender().sendString(1104, GetForlvl(8, player) + "Square Shield" + GetForlvl(8, player));
    		player.getPacketSender().sendString(1103, GetForlvl(7, player) + "Full Helm" + GetForlvl(7, player));
    		player.getPacketSender().sendString(1106, GetForlvl(7, player) + "Throwing Knives" + GetForlvl(7, player));
    		player.getPacketSender().sendString(1086, GetForlvl(6, player) + "Long Sword" + GetForlvl(6, player));
    		player.getPacketSender().sendString(1087, GetForlvl(5, player) + "Scimitar" + GetForlvl(5, player));
    		player.getPacketSender().sendString(1108, GetForlvl(5, player) + "Arrowtips" + GetForlvl(5, player));
    		player.getPacketSender().sendString(1085, GetForlvl(4, player) + "Sword" + GetForlvl(4, player));
    		player.getPacketSender().sendString(1107, GetForlvl(4, player) + "Bolts" + GetForlvl(4, player));
    		player.getPacketSender().sendString(13358, GetForlvl(4, player) + "Nails" + GetForlvl(4, player));
    		player.getPacketSender().sendString(1102, GetForlvl(3, player) + "Medium Helm" + GetForlvl(3, player));
    		player.getPacketSender().sendString(1093, GetForlvl(2, player) + "Mace" + GetForlvl(2, player));
    		player.getPacketSender().sendString(1094, GetForlvl(1, player) + "Dagger" + GetForlvl(1, player));
    		player.getPacketSender().sendString(1091, GetForlvl(1, player) + "Hatchet" + GetForlvl(1, player));
    		player.getPacketSender().sendString(8429, GetForlvl(8, player) + "Claws" + GetForlvl(8, player));
    		player.getPacketSender().sendSmithingData(1205,0,1119,1);
    		player.getPacketSender().sendSmithingData(1351,0,1120,1);
    		player.getPacketSender().sendSmithingData(1103,0,1121,1);
    		player.getPacketSender().sendSmithingData(1139,0,1122,1);
    		player.getPacketSender().sendSmithingData(819,0,1123,10);
    		player.getPacketSender().sendSmithingData(1277,1,1119,1);
    		player.getPacketSender().sendSmithingData(1422,1,1120,1);
    		player.getPacketSender().sendSmithingData(1075,1,1121,1);
    		player.getPacketSender().sendSmithingData(1155,1,1122,1);
    		player.getPacketSender().sendSmithingData(39,1,1123,15);
    		player.getPacketSender().sendSmithingData(1321,2,1119,1);
    		player.getPacketSender().sendSmithingData(1337,2,1120,1);
    		player.getPacketSender().sendSmithingData(1087,2,1121,1);
    		player.getPacketSender().sendSmithingData(1173,2,1122,1);
    		player.getPacketSender().sendSmithingData(864,2,1123,5);
    		player.getPacketSender().sendSmithingData(1291,3,1119,1);
    		player.getPacketSender().sendSmithingData(1375,3,1120,1);
    		player.getPacketSender().sendSmithingData(1117,3,1121,1);
    		player.getPacketSender().sendSmithingData(1189,3,1122,1);
    		player.getPacketSender().sendSmithingData(1307,4,1119,1);
    		player.getPacketSender().sendSmithingData(4819,4,1122,15);
    		player.getPacketSender().sendSmithingData(3095,4,1120, 1);
    		player.getPacketSender().sendSmithingData(-1,3,1123, 1);
    		player.getPacketSender().sendString(1135, "");
    		player.getPacketSender().sendString(1134, "");
    		player.getPacketSender().sendString(11461, "");
    		player.getPacketSender().sendString(11459, "");
    		player.getPacketSender().sendString(1132, "");
    		player.getPacketSender().sendString(1096, "");
    thats a lot of packets being sent in 1 tick for just 1 person.
    It's the "if it works, why change it?" mentality that goes around here. They will only start to realize what's wrong with what they're doing when the effects of the unoptimized code finally start showing out, however by that time it's basically too late and you're just better off taking a clean source and starting all over.
    Spoiler for sig too large:

    [Only registered and activated users can see links. ]

    Discord: Kris#1337
    Reply With Quote  
     

  3. #33  
    Registered Member
    Join Date
    Jun 2019
    Posts
    76
    Thanks given
    26
    Thanks received
    14
    Rep Power
    46
    Quote Originally Posted by Jack View Post
    Aaaaand just to follow up on this post. Took a few minutes to look at the interfaces and test out the different byte configs.

    Code:
    byte configs (packet 36)
    id: 210
    states: 0 - 5 (the amount of bars the player has)
    
    id: 211
    states: 0 - 99 (The levels the player meets for the different items - changes the item names from red to white or the other way around)
    
    id 262.
    states: 0 - 1 (if the oil lamp is available to smith)
    Code:
    		int bars = 20;
    		int smithLevel = 99;
    		boolean meetsRequirementsForOilLamp = true;
    		player.send(new ByteConfig(210, bars));
    		player.send(new ByteConfig(211, smithLevel));
    		player.send(new ByteConfig(262, meetsRequirementsForOilLamp ? 1 : 0));
    		player.send(new Interface(994));


    update
    Code:
    Item group ids (1119, 1120, 1121, 1122, 1123, 8430, 11460)
    Hi Jack, I'm going to rewrite Oak's smithing using configs I see indeed that this lights up the text etc. But how do I send the correct items. Like for instance bronze interface, iron, rune etc.

    Currently, the interface with these configs using a test command looks like this:



    Or do we still have to send the item packet?

    Code:
    player.getPacketSender().sendItemOnInterfaceSlot(b.getItemFrame(), b.getItemId(), b.getAmount(), b.getItemSlot());
    But that is still like what 30 packets per player using the smithing interface?

    Would appreciate the help .




    VS

    Code:
    /**
         * This method is triggered when a player clicks
         * on an anvil in the game.
         *
         * We will search for bars and then open the
         * corresponding interface if one was found.
         *
         * @param player
         */
        public static void openInterface(Player player) {
            //Search for bar..
            Optional<Bar> bar = Optional.empty();
            for(Bar b : Bar.values()) {
                if(!b.getItems().isPresent()) {
                    continue;
                }
                if(player.getInventory().contains(b.getBar())) {
                    if(player.getSkillManager().getCurrentLevel(Skill.SMITHING) >= b.getLevelReq()) {
                        bar = Optional.of(b);
                    }
                }
            }
    
            //Did we find a bar in the player's inventory?
            if(bar.isPresent()) {
                //Go through the bar's items..
                for(SmithableEquipment b : bar.get().getItems().get()) {
                    player.getPacketSender().sendItemOnInterfaceSlot(b.getItemFrame(), b.getItemId(), b.getAmount(), b.getItemSlot());
                    
                    int bars = player.getInventory().computeAmountForId(b.getBarId());
                    int smithLevel = player.getSkillManager().getCurrentLevel(Skill.SMITHING);
                    boolean meetsRequirementsForOilLamp = true;
                    player.getPacketSender().sendConfig(210, bars);
                    player.getPacketSender().sendConfig(211, smithLevel);
                    player.getPacketSender().sendConfig(262, meetsRequirementsForOilLamp ? 1 : 0);
                }
    
                //Send interface..
                player.getPacketSender().sendInterface(EQUIPMENT_CREATION_INTERFACE_ID);
            } else {
                player.message("You don't have any bars in your inventory which can be used with your Smithing level.");
            }
        }
    What could be changed and do you have an example?
    Reply With Quote  
     

  4. #34  
    Registered Member KronosRSPS's Avatar
    Join Date
    Aug 2019
    Posts
    53
    Thanks given
    5
    Thanks received
    13
    Rep Power
    29
    You'd be surprised how many 'modern' releases still contain code like this lol.
    Reply With Quote  
     

Page 4 of 4 FirstFirst ... 234

Thread Information
Users Browsing this Thread

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

Similar Threads

  1. Replies: 11
    Last Post: 12-04-2015, 12:29 PM
  2. Selling ALL Music data (enum)
    By MrClassic in forum Selling
    Replies: 19
    Last Post: 08-02-2014, 03:03 PM
  3. Smithing data
    By Cadillac in forum Requests
    Replies: 1
    Last Post: 07-29-2014, 09:13 PM
  4. Removing Unneeded Data in Enum
    By Scott Perretta in forum Snippets
    Replies: 23
    Last Post: 12-20-2012, 06:48 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
  •