RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SendGroundItem.java
1package com.osroyale.net.packet.out;
2
3import com.osroyale.net.codec.ByteOrder;
4import com.osroyale.net.codec.ByteModification;
5import com.osroyale.game.world.entity.mob.player.Player;
6import com.osroyale.game.world.items.ground.GroundItem;
7import com.osroyale.net.packet.OutgoingPacket;
8
35
36public class SendGroundItem extends OutgoingPacket {
37
38 private final GroundItem groundItem;
39 private GroundItemType type;
40
41 private SendGroundItem(GroundItem groundItem, GroundItemType type) {
42 super(44, 12);
43 this.groundItem = groundItem;
44 this.type = type;
45 }
46
47 public SendGroundItem(GroundItem groundItem) {
48 this(groundItem, GroundItemType.NORMAL);
49 }
50
51 @Override
52 public boolean encode(Player player) {
53 if (groundItem.instance != player.instance) {
54 return false;
55 }
56
57 if (!groundItem.isRegistered()) {
58 return false;
59 }
60
61 if (!groundItem.item.isTradeable()) {
62 this.type = GroundItemType.UNTRADEABLE;
63 } else if (groundItem.item.getValue() > 1_000_000) {
64 this.type = GroundItemType.RARE;
65 } else {
66 this.type = GroundItemType.NORMAL;
67 }
68
69 player.send(new SendCoordinate(groundItem.getPosition()));
70 builder.writeShort(groundItem.item.getId(), ByteModification.ADD, ByteOrder.LE)
71 .writeLong(groundItem.item.getAmount())
72 .writeByte(type.ordinal())
73 .writeByte(0);
74 return true;
75 }
76
77public enum GroundItemType {
78 NORMAL,
79 RARE,
80 UNTRADEABLE
81 }
82}