1package com.runehive.net.packet.out;
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.combat.hit.Hit;
7import com.runehive.game.world.entity.combat.hit.Hitsplat;
8import com.runehive.game.world.entity.mob.Direction;
9import com.runehive.game.world.entity.mob.Mob;
10import com.runehive.game.world.entity.mob.UpdateFlag;
11import com.runehive.game.world.entity.mob.Viewport;
12import com.runehive.game.world.entity.mob.player.ForceMovement;
13import com.runehive.game.world.entity.mob.player.Player;
14import com.runehive.game.world.entity.mob.player.appearance.Gender;
15import com.runehive.game.world.entity.mob.player.relations.ChatMessage;
16import com.runehive.game.world.items.Item;
17import com.runehive.game.world.items.containers.equipment.Equipment;
18import com.runehive.game.world.items.containers.equipment.EquipmentType;
19import com.runehive.game.world.position.Position;
20import com.runehive.net.codec.AccessType;
21import com.runehive.net.codec.ByteModification;
22import com.runehive.net.codec.ByteOrder;
23import com.runehive.net.packet.OutgoingPacket;
24import com.runehive.net.packet.PacketBuilder;
25import com.runehive.net.packet.PacketType;
26import com.runehive.util.Utility;
27import org.apache.logging.log4j.LogManager;
28import org.apache.logging.log4j.Logger;
30import java.util.Collection;
31import java.util.EnumSet;
32import java.util.Iterator;
81 for (
Player localPlayer : localPlayers) {
95 if (blockBuf.content().readableBytes() > 0) {
98 builder.writeBuffer(blockBuf.content());
102 }
catch (Exception ex) {
103 logger.error(String.format(
"error updating player=%s", player), ex);
125 final EnumSet<UpdateFlag> updateFlags = other.
updateFlags;
127 if (updateFlags.contains(flag) && flag.
canApply(player, other, state)) {
194 final int startX = otherPosition.
getLocalX(lastPosition);
195 final int startY = otherPosition.
getLocalY(lastPosition);
198 final int endX = end.
getX();
199 final int endY = end.
getY();
272 if (other.
id != -1) {
279 }
else if (helm !=
null && helm.
getId() > 1) {
312 }
else if (torso !=
null && torso.
getId() > 1) {
346 boolean beard =
true;
348 if (helm !=
null && helm.
getId() > 1) {
426 blockBuf.
writeByte(multipleHits ? 1 : 0);
431 if (health > max) health = max;
471 blockBuf.
writeByte(multipleHits ? 1 : 0);
475 if (health > max) health = max;
510 final boolean teleported = player.positionChange || player.
teleportRegion;
532 if (updateRequired) {
SkullHeadIconType getHeadIconType()
Gets the skull icon.
String getTitle()
Gets the title.
int getColor()
Gets the color.
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()
MobAnimation mobAnimation
final SkillManager skills
ForceMovement getForceMovement()
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.
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.
List< Player > getPlayersInViewport()
The collection of players in this viewport.
Direction lastDirection
The last direction the mob walked in.
int getWalkingDirection()
int getRunningDirection()
This class represents a character controlled by a player.
Optional< ChatMessage > getChatMessage()
final Equipment equipment
String getName()
Gets the name of this entity.
void send(OutgoingPacket encoder)
final Overrides overrides
Represents a chat message that can be displayed over an entities head.
static ChatMessage create(String message)
int getCombatLevel()
Gets the mob's combat level.
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
EquipmentType getEquipmentType()
final Item get(int index)
Gets the Item located on index.
The container that manages the equipment for a player.
static final int CHEST_SLOT
static final int AMULET_SLOT
static final int WEAPON_SLOT
static final int HEAD_SLOT
Equipment slot constants.
static final int SHIELD_SLOT
static final int FEET_SLOT
static final int LEGS_SLOT
static final int HELM_SLOT
static final int HANDS_SLOT
static final int CAPE_SLOT
Represents a single tile on the game world.
int getY()
Gets the absolute y coordinate.
int getX()
Gets the absolute x coordinate.
int getLocalY()
Gets the local y coordinate relative to this region.
int getLocalX()
Gets the local x coordinate relative to this region.
List< Player > getLocalPlayers(Mob mob)
Gets the local players 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 writeBytesReverse(byte[] data)
PacketBuilder writeBytes(byte[] from, int size)
PacketBuilder writeLong(long value)
PacketBuilder writeShort(int value)
PacketBuilder writeBit(boolean flag)
PacketBuilder writeInt(int value)
PacketBuilder writeBits(int amount, int value)
PacketBuilder writeByte(int value)
static PacketBuilder alloc(int initialCapacity, int maxCapacity)
PacketBuilder writeString(String string)
static void appendGraphicMask(Player other, PacketBuilder blockBuf)
static void appendFaceCoordinteMask(Player other, PacketBuilder blockBuf)
static void updateMovement(Player player, PacketBuilder packetBuf)
static void appendFaceEntityMask(Player other, PacketBuilder blockBuf)
static void appendAppearanceMask(Player other, PacketBuilder blockBuf)
static void appendSecondHitMask(final Player player, final PacketBuilder blockBuf)
static void appendChatMask(PacketBuilder blockBuf, Player other)
static void appendForceMovementMask(Player player, Player other, PacketBuilder blockBuf)
static final Logger logger
boolean encode(Player player)
static void appendForceChatMask(Player other, PacketBuilder blockBuf)
static void addNewPlayer(PacketBuilder packetBuf, Player player, Player other)
static void appendAnimationMask(Player other, PacketBuilder maskBuf)
static void updatePlayer(PacketBuilder blockBuf, Player player, Player other, UpdateState state)
static void appendHitMask(final Player player, final PacketBuilder blockBuf)
Handles miscellaneous methods.
static long hash(String input)
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 final UpdateFlag[] playerOrder
static boolean containsPlayer(int masks, UpdateFlag flag)
static String getCrown(Player player)
Gets the crown display.
Represents a gender for a player character.
The enumerated types of a players equipped item slots.
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.
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.
LE
Represents Little-endian.
Represents a type of packet.
VAR_SHORT
A variable packet where the size is indicated by a short.