Browse Source

Refactor out item useID

combat-2
MagicBot 8 months ago
parent
commit
96b4e1c639
  1. 11
      src/engine/net/client/handlers/ObjectActionMsgHandler.java
  2. 3
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java
  3. 13
      src/engine/objects/ItemBase.java
  4. 7
      src/engine/objects/ItemTemplate.java

11
src/engine/net/client/handlers/ObjectActionMsgHandler.java

@ -340,7 +340,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
pam.setX(loc.getX() + 64); //offset grid from tol pam.setX(loc.getX() + 64); //offset grid from tol
pam.setY(loc.getY()); pam.setY(loc.getY());
pam.setZ(loc.getZ() + 64); //offset grid from tol pam.setZ(loc.getZ() + 64); //offset grid from tol
pam.addPlacementInfo(ib.getUseID()); pam.addPlacementInfo(item.template.deed_structure_id);
dispatch = Dispatch.borrow(player, pam); dispatch = Dispatch.borrow(player, pam);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
@ -529,9 +529,12 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
DispatchMessage.sendToAllInRange(player, vum); DispatchMessage.sendToAllInRange(player, vum);
} }
if (waterbucketBypass == false) if (waterbucketBypass == false) {
PowersManager.applyPower(player, target, Vector3fImmutable.ZERO, ib.getUseID(), ib.getUseAmount(), true); String powerString = item.template.item_power_action.keySet().iterator().next();
int powerToken = PowersManager.ActionTokenByIDString.get(powerString);
int powerValue = item.template.item_power_action.get(powerString)[0];
PowersManager.applyPower(player, target, Vector3fImmutable.ZERO, powerToken, powerValue, true);
}
itemMan.consume(item); itemMan.consume(item);
} else //just remove the item at this point } else //just remove the item at this point
itemMan.consume(item); itemMan.consume(item);

3
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -347,7 +347,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
Item contract = null; Item contract = null;
for (Item inventoryItem : playerCharacter.getInventory()) { for (Item inventoryItem : playerCharacter.getInventory()) {
if (inventoryItem.getItemBase().getUseID() == buildingList.getBlueprintUUID()) { if (inventoryItem.template.item_type.equals(ItemType.DEED) &&
inventoryItem.template.deed_structure_id == buildingList.getBlueprintUUID()) {
contract = inventoryItem; contract = inventoryItem;
break; break;
} }

13
src/engine/objects/ItemBase.java

@ -30,10 +30,7 @@ public class ItemBase {
public final int uuid; public final int uuid;
private final int modTable; private final int modTable;
private final int useID;
private int hashID; private int hashID;
private final byte useAmount;
private final short percentRequired; private final short percentRequired;
private final short defense; private final short defense;
private final float dexPenalty; private final float dexPenalty;
@ -51,8 +48,6 @@ public class ItemBase {
public ItemBase(ResultSet rs) throws SQLException { public ItemBase(ResultSet rs) throws SQLException {
this.uuid = rs.getInt("ID"); this.uuid = rs.getInt("ID");
this.useID = rs.getInt("useID");
this.useAmount = rs.getByte("useAmount");
this.modTable = rs.getInt("modTable"); this.modTable = rs.getInt("modTable");
this.hashID = rs.getInt("itemHashID"); this.hashID = rs.getInt("itemHashID");
@ -167,14 +162,6 @@ public class ItemBase {
} }
public int getUseID() {
return this.useID;
}
public byte getUseAmount() {
return this.useAmount;
}
public int getModTable() { public int getModTable() {
return modTable; return modTable;
} }

7
src/engine/objects/ItemTemplate.java

@ -84,6 +84,7 @@ public class ItemTemplate {
public static HashMap<String, Integer> item_power_grant = new HashMap<>(); public static HashMap<String, Integer> item_power_grant = new HashMap<>();
public HashMap<String, int[]> item_power_action = new HashMap<>(); public HashMap<String, int[]> item_power_action = new HashMap<>();
public HashMap<Enum.ResourceType, Integer> item_resource_cost = new HashMap<>(); public HashMap<Enum.ResourceType, Integer> item_resource_cost = new HashMap<>();
public int deed_structure_id;
public ItemTemplate(JSONObject jsonObject) { public ItemTemplate(JSONObject jsonObject) {
@ -368,6 +369,12 @@ public class ItemTemplate {
item_resource_cost.put(resource_type, resource_value); item_resource_cost.put(resource_type, resource_value);
} }
// Deed related fields
if (item_type.equals(Enum.ItemType.DEED)) {
deed_structure_id = ((Long) jsonObject.get("deed_structure_id")).intValue();
}
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} }

Loading…
Cancel
Save