Equipment slot refactor started.

This commit is contained in:
2024-03-08 12:19:57 -05:00
parent 7d1d8891ff
commit d8d017669a
15 changed files with 163 additions and 443 deletions
+12 -21
View File
@@ -48,7 +48,7 @@ public class Item extends AbstractWorldObject {
public int numberOfItems;
public float durabilityCurrent;
public int chargesRemaining;
public byte equipSlot;
public Enum.EquipSlotType equipSlot;
private boolean canDestroy;
private boolean isRandom = false;
private int value;
@@ -72,7 +72,7 @@ public class Item extends AbstractWorldObject {
this.template = ItemTemplate.itemTemplates.get(templateID);
this.chargesRemaining = this.template.item_initial_charges;
this.durabilityCurrent = this.template.combat_health_full;
this.equipSlot = 0;
this.equipSlot = EquipSlotType.NONE;
this.containerType = ItemContainerType.NONE;
this.numberOfItems = 1;
loadEnchantments();
@@ -139,7 +139,7 @@ public class Item extends AbstractWorldObject {
this.canDestroy = true;
this.equipSlot = rs.getByte("item_equipSlot");
this.equipSlot = EquipSlotType.values()[rs.getByte("item_equipSlot")];
this.numberOfItems = rs.getInt("item_numberOfItems");
@@ -176,7 +176,7 @@ public class Item extends AbstractWorldObject {
public static void _serializeForClientMsg(Item item, ByteBufferWriter writer,
boolean includeSlot) {
if (includeSlot)
writer.putInt(item.equipSlot);
writer.putInt(item.equipSlot.ordinal());
writer.putInt(0); // Pad
writer.putInt(item.getItemBase().getUUID());
@@ -198,9 +198,11 @@ public class Item extends AbstractWorldObject {
}
// Handle Hair / Beard / horns Color.
boolean isHair = (item.equipSlot == (byte) MBServerStatics.SLOT_HAIRSTYLE);
boolean isBeard = (item.equipSlot == (byte) MBServerStatics.SLOT_BEARDSTYLE);
boolean isHair = (item.equipSlot.equals(EquipSlotType.HAIR));
boolean isBeard = (item.equipSlot.equals(EquipSlotType.BEARD));
int itemColor = 0;
if (isHair || isBeard) {
PlayerCharacter pc = PlayerCharacter.getFromCache(item.ownerID);
if (pc != null)
@@ -713,11 +715,6 @@ public class Item extends AbstractWorldObject {
return canDestroy;
}
public byte getEquipSlot() {
return equipSlot;
}
public int getNumOfItems() {
return this.numberOfItems;
}
@@ -850,7 +847,7 @@ public class Item extends AbstractWorldObject {
this.ownerType = null;
this.containerType = Enum.ItemContainerType.NONE;
this.equipSlot = MBServerStatics.SLOT_UNEQUIPPED;
this.equipSlot = EquipSlotType.NONE;
}
protected synchronized boolean moveItemToInventory(PlayerCharacter pc) {
@@ -974,7 +971,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = pc.getObjectUUID();
this.ownerType = OwnerType.PlayerCharacter;
this.containerType = Enum.ItemContainerType.EQUIPPED;
this.equipSlot = slot;
this.equipSlot = EquipSlotType.values()[slot];
return true;
}
@@ -992,7 +989,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = npc.getObjectUUID();
this.ownerType = OwnerType.Npc;
this.containerType = Enum.ItemContainerType.EQUIPPED;
this.equipSlot = slot;
this.equipSlot = EquipSlotType.values()[slot];
return true;
}
@@ -1002,7 +999,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = npc.getObjectUUID();
this.ownerType = OwnerType.Mob;
this.containerType = Enum.ItemContainerType.EQUIPPED;
this.equipSlot = slot;
this.equipSlot = EquipSlotType.values()[slot];
return true;
}
@@ -1134,12 +1131,6 @@ public class Item extends AbstractWorldObject {
return effectNames;
}
public boolean validForItem(long flags) {
if (this.getItemBase() == null)
return false;
return this.getItemBase().validSlotFlag(flags);
}
public boolean validForInventory(ClientConnection origin, PlayerCharacter pc, CharacterItemManager charItemMan) {
if (origin == null || pc == null || charItemMan == null)