Originally Posted by
clem585
What are the exact changes you made to Toolbelt? Here are the compatible/incompatible changes for Java serializables:
https://docs.oracle.com/javase/1.5.0...sion.html#6678
Did you do any of this?
Code:
- Changing the declared type of a primitive field (ex: int, String, byte, etc...)
- Deleting fields
Thank you for the reply. I'll have a look at that for sure. I have posted the toolbelt.java old and new below for you to take a look at if possible. I've also tried changing the UID's, 8785635409322322662, local class serialVersionUID = -7244573478285647954
That did not work either.
Toolbelt.java(OLD)
Code:
package com.rs.game.player;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import com.rs.game.item.Item;
public class Toolbelt implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 8785635409322322662L;
/** The player. */
private transient Player player;
/** The Constant TOOLBELT_ITEMS. */
private static final int[] TOOLBELT_ITEMS = new int[] { 946, 1735, 1595, 1755, 1599, 1597, 1733, 1592, 5523, 13431,
307, 309, 311, 301, 303, 1265, 2347, 1351, 590, -1, 8794, 4, 9434, 11065, 1785, 2976, 1594, 5343, 5325,
5341, 5329, 233, 952, 305, 975, 11323, 2575, 2576, 13153, 10150 };
/** The Constant Config_IDS. */
private static final int[] Config_IDS = new int[] { 2438, 2439 };
/** The toolbelt items. */
public Map<Integer, Boolean> toolbeltItems;
/**
* Instantiates a new toolbelt.
*/
public Toolbelt() {
if (toolbeltItems == null)
toolbeltItems = new HashMap<Integer, Boolean>();
for (int items : TOOLBELT_ITEMS)
toolbeltItems.put(items, false);
}
/**
* Sets the player.
*
* @Param player the new player
*/
public void setPlayer(Player player) {
this.player = player;
}
public void init() {
refreshItems();
}
public void reset() { //Added this just as a test to see if it would work.
toolbeltItems.clear();
toolbeltItems = new HashMap<Integer, Boolean>();
for (int items : TOOLBELT_ITEMS)
toolbeltItems.put(items, false);
// player.sm("Toolbelt items reset.");
}
/**
* Adds the item.
*
* @Param item the item
* @Return true, if successful
*/
public boolean addItem(int itemId, Item item) {
if (toolbeltItems.get(item.getId()) == null) {
player.sm("item is null");
return false;
}
if (toolbeltItems.get(item.getId())) {
refreshItems();
player.sm(item.getName() + " is already in your toolbelt.");
return false;
}
player.getInventory().deleteItem(item);
toolbeltItems.put(item.getId(), true);
player.sm("The " + item.getName() + " has been added to your toolbelt.");
refreshItems();
return true;
}
public void printToolbelt() {
player.sm("" + toolbeltItems.get(946));
}
/**
* Check storage.
*
* @Param item the item
* @Return true, if successful
*/
public static boolean checkStorage(int item) {
for (int i = 0; i < TOOLBELT_ITEMS.length - 1; i++) {
if (item == TOOLBELT_ITEMS[i])
return true;
}
return false;
}
/**
* Check if the item is within the players' toolbelt.
*
* @Param item the item
* @Return true, if successful
*/
public boolean contains(int item) {
if (toolbeltItems.get(item) == null) {
return false;
}
return toolbeltItems.get(item);
}
/**
* Refresh items.
*/
public void refreshItems() {
int[] configValue = new int[Config_IDS.length];
for (int i = 0; i < TOOLBELT_ITEMS.length; i++) {
if (toolbeltItems.get(TOOLBELT_ITEMS[i]) == null)
continue;
boolean inToolbelt = toolbeltItems.get(TOOLBELT_ITEMS[i]);
if (!inToolbelt)
continue;
int index = (i / 20);
configValue[index] |= 1 << (i - (index * 20));
}
for (int i = 0; i < Config_IDS.length; i++) {
if (configValue[i] == 0)
continue;
player.getPackets().sendConfig(Config_IDS[i], configValue[i]);
}
}
/**
* Open toolbelt.
*/
public void openToolbelt() {
refreshItems();
player.getInterfaceManager().sendInterface(1178);
}
}
Toolbelt.java(NEW, not working)
Code:
package com.rs.game.player;
import java.io.Serializable;
import com.rs.game.item.Item;
public class Toolbelt implements Serializable {
private static final long serialVersionUID = -7244573478285647954L; // Tried changing, did not work.
private static final int[] TOOLBET_ITEMS = new int[] { 946, 1735, 1595, 1755, 1599, 1597, 1733, 1592, 5523, 13431,
307, 309, 311, 301, 303, 1265, 2347, 1351, 590, -1, 8794, 4, 9434, 11065, 1785, 2976, 1594, 5343, 5325,
5341, 5329, 233, 952, 305, 975, 11323, 2575, 2576, 13153, 10150,
// end of default items
1267, 1269, 1273, 1271, 1275, 15259, // pickaxes - normal
20780, 20781, 20782, 20784, 20783, 20785, 20786, // pickaxes - upgraded
13661, // inferno adze
1349, 1353, 1355, 1357, 1359, 6739 // hatchets
};
private static final int[] CONFIG_IDS = new int[] { 2438, 2439 };
private boolean[] items;
private transient Player player;
private boolean updated;
public Toolbelt() {
items = new boolean[TOOLBET_ITEMS.length];
}
public void setPlayer(Player player) {
this.player = player;
if (items != null && !updated) {
boolean newToolbelt[] = items;
items = new boolean[TOOLBET_ITEMS.length];
for (int i = 0; i < newToolbelt.length; i++) {
items[i] = newToolbelt[i];
}
updated = true;
}
}
public void init() {
refreshConfigs();
}
private int getConfigIndex(int i) {
return i / 20;
}
private void refreshConfigs() {
int[] configValues = new int[CONFIG_IDS.length];
for (int i = 0; i < items.length - 20; i++) {
if (items[i]) {
int index = getConfigIndex(i);
configValues[index] |= 1 << i - index * 20;
}
}
for (int i = 0; i < CONFIG_IDS.length; i++) {
player.getPackets().sendConfig(CONFIG_IDS[i], configValues[i]);
}
}
private int getItemSlot(int id) {
for (int i = 0; i < TOOLBET_ITEMS.length; i++) {
if (TOOLBET_ITEMS[i] == id) {
return i;
}
}
return -1;
}
public boolean addItem(int invSlot, Item item) {
int slot = getItemSlot(item.getId());
if (slot == -1) {
return false;
}
if (items[slot]) {
player.getPackets().sendInventoryMessage(0, invSlot, "That is already on your tool belt.");
} else {
items[slot] = true;
player.getInventory().deleteItem(invSlot, item);
refreshConfigs();
player.getPackets()
.sendGameMessage("You add the " + item.getDefinitions().getName() + " to your tool belt.");
}
return true;
}
public boolean containsItem(int id) {
int slot = getItemSlot(id);
return slot == -1 ? false : items[slot];
}
}