I'm a noob, sorry for all the questions.
EDIT: I have been able to add the item to the player but the item on the ground still remains, and unable to pick up again (which is good as thats what its meant to do). However, I can't seem to
remove the item after picking up
GlobalDropsHandler.java
Code:
public static void pickup(Client client, int itemId, int itemX, int itemY, int itemH) {
GlobalDrop drop = itemExists(itemId, itemX, itemY, itemH);
if (drop == null) {
return;
}
if (drop.isTaken()) {
return;
}
drop.setTakenAt(System.currentTimeMillis());
drop.setTaken(true);
if (client.getItemAssistant().freeSlots() > 0) {
System.out.println("pick up item"); //This prints on first time i pick up the item, but not after (which means it works but the model remains)
client.getItemAssistant().addItem(drop.getId(), drop.getAmount());
client.getActionSender().removeGroundItem(drop.getId(), drop.getX(), drop.getY(), drop.getAmount(),drop.getH());
globalDrops.remove(drop);
}
for (Player player : PlayerHandler.players) {
Client cl = (Client) player;
if (cl != null) {
if (cl.distanceToPoint(drop.getX(), drop.getY()) <= 60) {
cl.getActionSender().removeGroundItem(drop.getId(), drop.getX(), drop.getY(), drop.getAmount(),drop.getH());
}
}
}
}
In the PickUpItem.java
Code:
public class PickupItem implements PacketType {
@Override
public void processPacket(final Client player, int packetType, int packetSize) {
player.pItemY = player.getInStream().readSignedWordBigEndian();
player.pItemId = player.getInStream().readUnsignedWord();
player.pItemX = player.getInStream().readSignedWordBigEndian();
System.out.println("Step 1 - start pick up packet");
GlobalDropsHandler.pickup(player, player.pItemId, player.pItemX, player.pItemY, player.heightLevel);
Then in the ActionSender.java
Code:
public ActionSender removeGroundItem(int itemID, int itemX, int itemY, int Amount, int height) {
if (player == null) {
return this;
}
player.getOutStream().createFrame(85);
player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
player.getOutStream().createFrame(156);
player.getOutStream().writeByteS(height);
player.getOutStream().writeWord(itemID);
player.flushOutStream();
return this;
}
I've toiled away at this without much success. Any guidance would be appreciated.
Thanks.