RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SendItemOnInterfaceSlot.java
1package com.osroyale.net.packet.out;
2
3import com.osroyale.game.world.entity.mob.player.Player;
4import com.osroyale.game.world.items.Item;
5import com.osroyale.net.packet.OutgoingPacket;
6import com.osroyale.net.packet.PacketType;
7
31
32public class SendItemOnInterfaceSlot extends OutgoingPacket {
33 private final int interfaceId;
34 private final Item item;
35 private final int slot;
36
37 public SendItemOnInterfaceSlot(int interfaceId, int item, int slot) {
38 this(interfaceId, new Item(item, 1), slot);
39 }
40
41 public SendItemOnInterfaceSlot(int interfaceId, int item, int amount, int slot) {
42 this(interfaceId, new Item(item, amount), slot);
43 }
44
45 public SendItemOnInterfaceSlot(int interfaceId, Item item, int slot) {
46 super(34, PacketType.VAR_SHORT);
47 this.interfaceId = interfaceId;
48 this.item = item;
49 this.slot = slot;
50 }
51
52 @Override
53 public boolean encode(Player player) {
54 builder.writeShort(interfaceId);
55 builder.writeShort(slot);
56 if (item == null) {
57 builder.writeShort(0);
58 builder.writeByte(0);
59 } else {
60 builder.writeShort(item.getId() + 1);
61 final int amount = item.getAmount();
62 if (amount > 254) {
63 builder.writeByte(255);
64 builder.writeInt(amount);
65 } else {
66 builder.writeByte(amount);
67 }
68 }
69 return true;
70 }
71
72}