RuneHive-Game
Loading...
Searching...
No Matches
SendAddObject.java
Go to the documentation of this file.
1package com.runehive.net.packet.out;
2
3import com.runehive.net.codec.ByteOrder;
4import com.runehive.net.codec.ByteModification;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.object.GameObject;
7import com.runehive.net.packet.OutgoingPacket;
8
9public class SendAddObject extends OutgoingPacket {
10
11 private final GameObject object;
12
13 public SendAddObject(GameObject object) {
14 super(151, 4);
15 this.object = object;
16 }
17
18 @Override
19 public boolean encode(Player player) {
20 if (object.getInstancedHeight() != player.instance) {
21 return false;
22 }
23 player.send(new SendCoordinate(object.getPosition()));
24 builder.writeByte(0, ByteModification.ADD);
25 builder.writeShort(object.getId(), ByteOrder.LE);
26 builder.writeByte((object.getObjectType().getId() << 2) + (object.getDirection().getId() & 3), ByteModification.SUB);
27 return true;
28 }
29
30}
This class represents a character controlled by a player.
Definition Player.java:125
OutgoingPacket(int opcode, int capacity)
Represents RuneScape's custom value types.
SUB
Subtracts the value from 128 when written, adds 128 to the rarity when read.
ADD
Adds 128 to the value when written, subtracts 128 from the rarity when read.
Represents the order in which bytes are written.
Definition ByteOrder.java:8
LE
Represents Little-endian.