So after not finding a tutorial like this anywhere, I decided to develop it for myself and give back to the RSPS community to those learning to code and existing developers. I know it would be easier to use an Item Def Editor for any cache before 745, but anyone developing on the Valkyr or Helwyr sources that were released won't be able to add custom items due to most of them not having a working Item Def Editor.
STEP 1: Finding the Location for Your Code to Go
If you're using a standard 718 client, you're going to want to open up the file ItemDefinitions.java [de-obfuscated name of Class468] in Eclipse, or your default text editor. Search for the following method (depending on actual client, some fields/variables might be different, but it's the method that reads the opcodes from the server)
Code:
void decode(RsByteBuffer stream, int opcode) {
try {
if (1 == opcode)
this.invModelId = (stream.readBigSmart(1235052657));
Under the else if statement for Opcode #249, there should be a for each statement for processing the client script maps. (In layman's terms, this means it runs for each value (item id) in a given list (array)) Directly below this for each statement is going to be where you will be creating your custom items.
STEP 2: Building your custom item from existing models and color codes
So for this example I will be turning the off-white partyhat item (Item Id #28702) into a lava colored partyhat with the name Example partyhat and the color of lava yellow. Paste this blank snippet below the for each statement. (If it gives you compile errors, please load it in eclipse as this will help you track down the actual variable name (depending on client))
Code:
if(name.equalsIgnoreCase(""))
{
name = "";
aStringArray5732[1] = "Wear";
maleEquipModelId1 = ;
femaleEquipModelId1 = ;
originalModelColors[0] = ;
modifiedModelColors[0] = (short) ;
}
So comparatively, my complete edited working statement would be:
Code:
if(name.equalsIgnoreCase("off-white partyhat")){
name = "Example Partyhat";
aStringArray5732[1] = "Wear";
maleEquipModelId1 = 187;
femaleEquipModelId1 = 363;
originalModelColors[0] = 926;
modifiedModelColors[0] = (short) 6073;
}
So to give some context to what exactly each line of code does, so you can make your own items....
Line #1: To determine what item name you will be changing, this could be anything from "bandos godsword" to "obsidian gloves". Just make sure it's an item that's never going to be used, it cannot be a null
Line #2: This changes the item name - client sided only, the server will still think it is called "off-white partyhat"
Line #3: This adds the wear option to the inventory options on the client side of things. (Server side code coming below)
Line #4: This changes the Male model ID in the cache that you will be using, and then modifying. (187 is universal male phat model #)
Line #5: This changes the Female model ID in the cache that you will be using, and then modifying. (363 is universal female phat model #)
Line #6: This sets the original model color that you will be changing, I didn't make the color white for mine, and it still worked in-game.
Line #7: This sets the new color code for your item, 6073 is lava. I will link the color ID list I used from CNova below.
STEP 3: Letting your source know that you're making some mods to an item.
This step is crucial when adding any type of custom colored equipment or else the server will reject the client's request to equip the item, or equip it in the wrong item slot. Navigate to your Equiptment.java file in your Source and find the getItemSlot method. Add the following statement below it.
Code:
if (itemId == 28703)
return Equipment.SLOT_HAT;
Make sure to change the Item ID to the Item ID that you are replacing and change the Equipment Enum/byte to the proper equipment slot. The full list of them should be at the start of the class. (Ex. If you're making a custom Spirit Shield, it would be Equipment.SLOT_SHIELD instead)
STEP 4: Save and Compile!
Save and compile your source and client (if you're in eclipse just make sure the files are saved) and then log in and spawn your item!
Resources
IDE Model Colour ID's
Please let me know if this helps you as a developer, as that will encourage me to share more tutorials for things that I had to figure out myself due to lack of resources out there.