1package com.runehive.net.packet.out;
3import com.runehive.Config;
4import com.runehive.game.Animation;
5import com.runehive.game.Graphic;
6import com.runehive.game.world.World;
7import com.runehive.game.world.entity.combat.hit.Hit;
8import com.runehive.game.world.entity.combat.hit.Hitsplat;
9import com.runehive.game.world.entity.mob.Direction;
10import com.runehive.game.world.entity.mob.Mob;
11import com.runehive.game.world.entity.mob.UpdateFlag;
12import com.runehive.game.world.entity.mob.Viewport;
13import com.runehive.game.world.entity.mob.movement.Movement;
14import com.runehive.game.world.entity.mob.npc.Npc;
15import com.runehive.game.world.entity.mob.player.Player;
16import com.runehive.game.world.position.Position;
17import com.runehive.net.codec.AccessType;
18import com.runehive.net.codec.ByteModification;
19import com.runehive.net.codec.ByteOrder;
20import com.runehive.net.packet.OutgoingPacket;
21import com.runehive.net.packet.PacketBuilder;
22import com.runehive.net.packet.PacketType;
24import java.util.Arrays;
25import java.util.EnumSet;
26import java.util.Iterator;
80 if (localNpc.atomicPlayerCount.incrementAndGet() < 0) {
81 localNpc.atomicPlayerCount.set(0);
87 if (maskBuf.content().readableBytes() > 0) {
90 builder.writeBytes(maskBuf.content());
95 }
catch (Exception ex) {
119 if (runDirection != -1) {
122 .writeBits(3, walkDirection)
123 .writeBits(3, runDirection)
124 .writeBit(updateRequired);
125 }
else if (walkDirection != -1) {
128 .writeBits(3, walkDirection)
129 .writeBit(updateRequired);
131 packet.writeBit(updateRequired);
132 if (updateRequired) {
145 final EnumSet<UpdateFlag> updateFlags = npc.
updateFlags;
147 if (updateFlags.contains(flag) && flag.
canApply(npc)) {
246 updateBlock.
writeByte(multipleHits ? 1 : 0);
250 if (health > max) health = max;
306 boolean isMultipleHits = multipleHits !=
null;
307 Hit[] multipleHitsArray = isMultipleHits ? Arrays.copyOf(multipleHits, multipleHits.length) :
null;
308 updateBlock.
writeByte(isMultipleHits ? 1 : 0);
312 if (health > max) health = max;
315 updateBlock.
writeByte(multipleHitsArray.length);
316 for (
Hit currentHit : multipleHitsArray) {
317 int id = currentHit.getHitsplat().getId();
320 && currentHit.getDamage() > 0) {
324 updateBlock.
writeByte(currentHit.getDamage());
326 updateBlock.
writeByte(currentHit.getHitIcon().getId());
The class that contains setting-related constants for the server.
static final int NPC_BITS
The npc bits for the server which can execute 6755 npcs.
Class that models a single animation used by an entity.
int getId()
Gets the animation id.
static final Animation RESET
int getDelay()
Gets the animation delay.
Represents a single graphic that can be used by entities.
static final Graphic RESET
int getDelay()
Gets the delay of this graphic.
int getId()
Gets the id of this graphic.
int getHeight()
Gets the height of this graphic.
Represents the game world.
static RegionManager getRegions()
A Hit object holds the damage amount and hitsplat data.
int getDamage()
Gets the damage amount.
Hitsplat getHitsplat()
Gets the damage type.
HitIcon getHitIcon()
Gets the hit icon.
Optional< Graphic > getGraphic()
final EnumSet< UpdateFlag > updateFlags
boolean isUpdateRequired()
Checks if mob requires an update.
Optional< Animation > getAnimation()
final boolean isPlayer()
Check if an entity is a player.
Represents a viewport in which a Player can see.
boolean add(Mob other)
Adds a Mob to this viewport.
List< Npc > getNpcsInViewport()
The collection of npcs in this viewport.
boolean shouldRemove(Mob other)
Determines if a Mob should be removed from this viewport.
static final int ADD_THRESHOLD
The amount of entities that can be added to this viewport in a single tick.
static final int CAPACITY
The amount of entities that can be visible at all at once 255 players and 255 npcs.
Handles the movement for the player.
Direction lastDirection
The last direction the mob walked in.
int getWalkingDirection()
int getRunningDirection()
Represents a non-player character in the in-game world.
final AtomicInteger atomicPlayerCount
This class represents a character controlled by a player.
Represents a single tile on the game world.
int getY()
Gets the absolute y coordinate.
int getX()
Gets the absolute x coordinate.
List< Npc > getLocalNpcs(Mob mob)
Gets the local npcs around an entity.
final PacketBuilder builder
OutgoingPacket(int opcode, int capacity)
The implementation that functions as a dynamic buffer wrapper backed by a ByteBuf that is used for re...
PacketBuilder writeShort(int value)
PacketBuilder writeInt(int value)
PacketBuilder writeByte(int value)
static PacketBuilder alloc(int initialCapacity, int maxCapacity)
PacketBuilder writeString(String string)
static void appendAnimationMask(Npc npc, PacketBuilder maskBuf)
static void appendTransformationMask(Npc npc, PacketBuilder maskBuf)
static void updateMovement(PacketBuilder packet, Npc npc)
static void appendGfxMask(Npc npc, PacketBuilder maskBuf)
static void appendSecondHitMask(final Npc npc, final PacketBuilder updateBlock)
static void appendFaceCoordinateMask(Npc npc, PacketBuilder maskBuf)
static void updateNpc(PacketBuilder maskBuf, Npc npc)
static void addNewNpc(PacketBuilder packet, Player player, Npc npc)
static void appendFaceEntityMask(Npc npc, PacketBuilder maskBuf)
static void appendFirstHitMask(final Npc npc, final PacketBuilder updateBlock)
static void appendForceChatMask(Npc npc, PacketBuilder maskBuf)
boolean encode(Player player)
final int getId()
Gets the identification for this hit type.
NORMAL
Represents a normal hit type.
final int getId()
Gets the identification for this hit type.
Represents the enumerated directions an entity can walk or face.
boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state)
static boolean containsNpc(int masks, UpdateFlag flag)
static final UpdateFlag[] npcOrder
Represents the different forms data can be written in.
BIT
The type that denotes bits can be written as bytes.
BYTE
the type that denotes bytes can be written directly.
Represents RuneScape's custom value types.
ADD
Adds 128 to the value when written, subtracts 128 from the rarity when read.
Represents the order in which bytes are written.
LE
Represents Little-endian.
Represents a type of packet.
VAR_SHORT
A variable packet where the size is indicated by a short.