mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Comment and naming improvements and clarifications.
This commit is contained in:
@@ -10,6 +10,11 @@ import org.apollo.game.sync.block.SynchronizationBlock;
|
||||
*/
|
||||
public final class Npc extends Mob {
|
||||
|
||||
/**
|
||||
* This npc's id.
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* The positions representing the bounds (i.e. walking limits) of this npc.
|
||||
*/
|
||||
@@ -34,6 +39,7 @@ public final class Npc extends Mob {
|
||||
public Npc(NpcDefinition definition, Position position) {
|
||||
super(position);
|
||||
this.definition = definition;
|
||||
this.id = definition.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,12 +57,12 @@ public final class Npc extends Mob {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id of this npc. Shorthand for {@link #getDefinition().getId()}.
|
||||
* Gets the id of this npc.
|
||||
*
|
||||
* @return The id.
|
||||
*/
|
||||
public int getId() {
|
||||
return definition.getId();
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +100,7 @@ public final class Npc extends Mob {
|
||||
if (id < 0 || id >= NpcDefinition.count()) {
|
||||
throw new IllegalArgumentException("Id to transform to is out of bounds.");
|
||||
}
|
||||
definition = NpcDefinition.lookup(id);
|
||||
definition = NpcDefinition.lookup(this.id = id);
|
||||
blockSet.add(SynchronizationBlock.createTransformBlock(id));
|
||||
}
|
||||
|
||||
|
||||
@@ -99,9 +99,9 @@ public final class Player extends Mob {
|
||||
private List<String> friends = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* This player's head icon.
|
||||
* Whether or not the player is skulled.
|
||||
*/
|
||||
private int headIcon = -1;
|
||||
private boolean isSkulled = false;
|
||||
|
||||
/**
|
||||
* The list of usernames of players this player has ignored.
|
||||
@@ -348,12 +348,12 @@ public final class Player extends Mob {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's head icon.
|
||||
* Indicates whether or not the player is skulled
|
||||
*
|
||||
* @return The head icon.
|
||||
* @return {@code true} if the player is skulled, otherwise {@code false}.
|
||||
*/
|
||||
public int getHeadIcon() {
|
||||
return headIcon;
|
||||
public boolean isSkulled() {
|
||||
return isSkulled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -810,12 +810,12 @@ public final class Player extends Mob {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player's head icon.
|
||||
* Sets whether or not the player is skulled.
|
||||
*
|
||||
* @param headIcon The head icon.
|
||||
* @param isSkulled Whether or not the player is skulled.
|
||||
*/
|
||||
public void setHeadIcon(int headIcon) {
|
||||
this.headIcon = headIcon;
|
||||
public void setSkulled(boolean isSkulled) {
|
||||
this.isSkulled = isSkulled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,9 +26,9 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
||||
private final Inventory equipment;
|
||||
|
||||
/**
|
||||
* The player's head icon.
|
||||
* Whether or not the player is skulled.
|
||||
*/
|
||||
private final int headIcon;
|
||||
private final boolean isSkulled;
|
||||
|
||||
/**
|
||||
* The player's name.
|
||||
@@ -43,7 +43,7 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
||||
/**
|
||||
* The player's prayer icon.
|
||||
*/
|
||||
private final int prayerIcon;
|
||||
private final int headIcon;
|
||||
|
||||
/**
|
||||
* The player's total skill level (or 0).
|
||||
@@ -58,12 +58,12 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
||||
* @param combat The player's combat.
|
||||
* @param skill The player's skill, or 0 if showing the combat level.
|
||||
* @param equipment The player's equipment.
|
||||
* @param prayerIcon The prayer icon id of this player.
|
||||
* @param headIcon The head icon id of this player.
|
||||
* @param headIcon The head icon id of the player.
|
||||
* @param isSkulled Whether or not the player is skulled.
|
||||
*/
|
||||
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int prayerIcon,
|
||||
int headIcon) {
|
||||
this(name, appearance, combat, skill, equipment, prayerIcon, headIcon, -1);
|
||||
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon,
|
||||
boolean isSkulled) {
|
||||
this(name, appearance, combat, skill, equipment, headIcon, isSkulled, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,19 +74,19 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
||||
* @param combat The player's combat.
|
||||
* @param skill The player's skill, or 0 if showing the combat level.
|
||||
* @param equipment The player's equipment.
|
||||
* @param prayerIcon The prayer icon id of this player.
|
||||
* @param headIcon The head icon id of this player.
|
||||
* @param headIcon The prayer icon id of this player.
|
||||
* @param isSkulled Whether or not the player is skulled.
|
||||
* @param npcId The npc id of the player, if they are appearing as an npc, (otherwise {@code -1}).
|
||||
*/
|
||||
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int prayerIcon,
|
||||
int headIcon, int npcId) {
|
||||
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon,
|
||||
boolean isSkulled, int npcId) {
|
||||
this.name = name;
|
||||
this.appearance = appearance;
|
||||
this.combat = combat;
|
||||
this.skill = skill;
|
||||
this.equipment = equipment.clone();
|
||||
this.prayerIcon = prayerIcon;
|
||||
this.headIcon = headIcon;
|
||||
this.isSkulled = isSkulled;
|
||||
this.npcId = npcId;
|
||||
}
|
||||
|
||||
@@ -127,12 +127,12 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's head icon.
|
||||
* Whether or not the player is skulled.
|
||||
*
|
||||
* @return The head icon.
|
||||
* @return {@code true} if the player is skulled, otherwise {@code false}.
|
||||
*/
|
||||
public int getHeadIcon() {
|
||||
return headIcon;
|
||||
public boolean isSkulled() {
|
||||
return isSkulled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,12 +154,12 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's prayer icon.
|
||||
* Gets the player's head icon.
|
||||
*
|
||||
* @return The prayer icon.
|
||||
* @return The head icon.
|
||||
*/
|
||||
public int getPrayerIcon() {
|
||||
return prayerIcon;
|
||||
public int getHeadIcon() {
|
||||
return headIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class SynchronizationBlock {
|
||||
*/
|
||||
public static SynchronizationBlock createAppearanceBlock(Player player) {
|
||||
return new AppearanceBlock(player.getEncodedName(), player.getAppearance(), player.getSkillSet()
|
||||
.getCombatLevel(), 0, player.getEquipment(), player.getPrayerIcon(), player.getHeadIcon(),
|
||||
.getCombatLevel(), 0, player.getEquipment(), player.getPrayerIcon(), player.isSkulled(),
|
||||
player.getDefinition() == null ? -1 : player.getDefinition().getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,12 @@ import java.util.List;
|
||||
import org.apollo.game.event.impl.NpcSynchronizationEvent;
|
||||
import org.apollo.game.model.Npc;
|
||||
import org.apollo.game.model.Player;
|
||||
import org.apollo.game.model.Position;
|
||||
import org.apollo.game.model.World;
|
||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||
import org.apollo.game.sync.seg.AddNpcSegment;
|
||||
import org.apollo.game.sync.seg.MovementSegment;
|
||||
import org.apollo.game.sync.seg.RemoveMobSegment;
|
||||
import org.apollo.game.sync.seg.SynchronizationSegment;
|
||||
import org.apollo.util.MobRepository;
|
||||
|
||||
/**
|
||||
* A {@link SynchronizationTask} which synchronizes npcs with the specified {@link Player}.
|
||||
@@ -44,15 +43,15 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SynchronizationBlockSet blockSet = player.getBlockSet();
|
||||
List<Npc> localNpcs = player.getLocalNpcList();
|
||||
List<SynchronizationSegment> segments = new ArrayList<>();
|
||||
int oldLocalNpcs = localNpcs.size();
|
||||
List<SynchronizationSegment> segments = new ArrayList<SynchronizationSegment>();
|
||||
final Position playerPosition = player.getPosition();
|
||||
|
||||
for (Iterator<Npc> it = localNpcs.iterator(); it.hasNext();) {
|
||||
Npc npc = it.next();
|
||||
if (!npc.isActive() || npc.isTeleporting()
|
||||
|| npc.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
|
||||
|| npc.getPosition().getLongestDelta(playerPosition) > player.getViewingDistance()) {
|
||||
it.remove();
|
||||
segments.add(new RemoveMobSegment());
|
||||
} else {
|
||||
@@ -62,8 +61,7 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
|
||||
|
||||
int added = 0;
|
||||
|
||||
MobRepository<Npc> repository = World.getWorld().getNpcRepository();
|
||||
for (Npc npc : repository) {
|
||||
for (Npc npc : World.getWorld().getNpcRepository()) {
|
||||
if (localNpcs.size() >= 255) {
|
||||
player.flagExcessiveNpcs();
|
||||
break;
|
||||
@@ -71,19 +69,17 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
|
||||
break;
|
||||
}
|
||||
|
||||
if (npc.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance())
|
||||
&& !localNpcs.contains(npc)) {
|
||||
Position npcPosition = npc.getPosition();
|
||||
if (npcPosition.isWithinDistance(playerPosition, player.getViewingDistance()) && !localNpcs.contains(npc)
|
||||
&& npcPosition.getHeight() == playerPosition.getHeight()) {
|
||||
localNpcs.add(npc);
|
||||
added++;
|
||||
npc.turnTo(npc.getFacingPosition());
|
||||
blockSet = npc.getBlockSet();
|
||||
segments.add(new AddNpcSegment(blockSet, npc.getIndex(), npc.getPosition(), npc.getDefinition()
|
||||
.getId()));
|
||||
segments.add(new AddNpcSegment(npc.getBlockSet(), npc.getIndex(), npcPosition, npc.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
NpcSynchronizationEvent event = new NpcSynchronizationEvent(player.getPosition(), segments, oldLocalNpcs);
|
||||
player.send(event);
|
||||
player.send(new NpcSynchronizationEvent(playerPosition, segments, oldLocalNpcs));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -88,21 +88,21 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
* Puts an animation block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder builder) {
|
||||
Animation animation = block.getAnimation();
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, animation.getId());
|
||||
blockBuilder.put(DataType.BYTE, animation.getDelay());
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, animation.getId());
|
||||
builder.put(DataType.BYTE, animation.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the blocks for the specified segment.
|
||||
*
|
||||
* @param segment The segment.
|
||||
* @param blockBuilder The block builder.
|
||||
* @param builder The block builder.
|
||||
*/
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder blockBuilder) {
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder builder) {
|
||||
SynchronizationBlockSet blockSet = segment.getBlockSet();
|
||||
if (blockSet.size() > 0) {
|
||||
int mask = 0;
|
||||
@@ -139,38 +139,38 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
mask |= 0x4;
|
||||
}
|
||||
|
||||
blockBuilder.put(DataType.BYTE, mask);
|
||||
builder.put(DataType.BYTE, mask);
|
||||
|
||||
if (blockSet.contains(AnimationBlock.class)) {
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), blockBuilder);
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(HitUpdateBlock.class)) {
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), blockBuilder);
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(GraphicBlock.class)) {
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), blockBuilder);
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(InteractingMobBlock.class)) {
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), blockBuilder);
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(ForceChatBlock.class)) {
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), blockBuilder);
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(SecondaryHitUpdateBlock.class)) {
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), blockBuilder);
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(TransformBlock.class)) {
|
||||
putTransformBlock(blockSet.get(TransformBlock.class), blockBuilder);
|
||||
putTransformBlock(blockSet.get(TransformBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(TurnToPositionBlock.class)) {
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), blockBuilder);
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,12 +189,12 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
* Puts a graphic block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putGraphicBlock(GraphicBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putGraphicBlock(GraphicBlock block, GamePacketBuilder builder) {
|
||||
Graphic graphic = block.getGraphic();
|
||||
blockBuilder.put(DataType.SHORT, graphic.getId());
|
||||
blockBuilder.put(DataType.INT, graphic.getDelay());
|
||||
builder.put(DataType.SHORT, graphic.getId());
|
||||
builder.put(DataType.INT, graphic.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,12 +290,12 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
* Puts a turn to position block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putTurnToPositionBlock(TurnToPositionBlock block, GamePacketBuilder blockBuilder) {
|
||||
Position pos = block.getPosition();
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, pos.getX() * 2 + 1);
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, pos.getY() * 2 + 1);
|
||||
private void putTurnToPositionBlock(TurnToPositionBlock block, GamePacketBuilder builder) {
|
||||
Position position = block.getPosition();
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, position.getX() * 2 + 1);
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, position.getY() * 2 + 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,21 +101,21 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
* Puts an animation block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder builder) {
|
||||
Animation animation = block.getAnimation();
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, animation.getId());
|
||||
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE, animation.getDelay());
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, animation.getId());
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, animation.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an appearance block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putAppearanceBlock(AppearanceBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putAppearanceBlock(AppearanceBlock block, GamePacketBuilder builder) {
|
||||
Appearance appearance = block.getAppearance();
|
||||
GamePacketBuilder playerProperties = new GamePacketBuilder();
|
||||
|
||||
@@ -219,18 +219,18 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
playerProperties.put(DataType.BYTE, block.getCombatLevel());
|
||||
playerProperties.put(DataType.SHORT, block.getSkillLevel());
|
||||
|
||||
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE, playerProperties.getLength());
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, playerProperties.getLength());
|
||||
|
||||
blockBuilder.putRawBuilder(playerProperties);
|
||||
builder.putRawBuilder(playerProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the blocks for the specified segment.
|
||||
*
|
||||
* @param segment The segment.
|
||||
* @param blockBuilder The block builder.
|
||||
* @param builder The block builder.
|
||||
*/
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder blockBuilder) {
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder builder) {
|
||||
SynchronizationBlockSet blockSet = segment.getBlockSet();
|
||||
if (blockSet.size() > 0) {
|
||||
int mask = 0;
|
||||
@@ -268,40 +268,40 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
|
||||
if (mask >= 0x100) {
|
||||
mask |= 0x40;
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, mask);
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, mask);
|
||||
} else {
|
||||
blockBuilder.put(DataType.BYTE, mask);
|
||||
builder.put(DataType.BYTE, mask);
|
||||
}
|
||||
|
||||
if (blockSet.contains(ForceMovementBlock.class)) {
|
||||
putForceMovementBlock(blockSet.get(ForceMovementBlock.class), blockBuilder);
|
||||
putForceMovementBlock(blockSet.get(ForceMovementBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(GraphicBlock.class)) {
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), blockBuilder);
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(AnimationBlock.class)) {
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), blockBuilder);
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(ForceChatBlock.class)) {
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), blockBuilder);
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(ChatBlock.class)) {
|
||||
putChatBlock(blockSet.get(ChatBlock.class), blockBuilder);
|
||||
putChatBlock(blockSet.get(ChatBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(InteractingMobBlock.class)) {
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), blockBuilder);
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(AppearanceBlock.class)) {
|
||||
putAppearanceBlock(blockSet.get(AppearanceBlock.class), blockBuilder);
|
||||
putAppearanceBlock(blockSet.get(AppearanceBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(TurnToPositionBlock.class)) {
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), blockBuilder);
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(HitUpdateBlock.class)) {
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), blockBuilder);
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(SecondaryHitUpdateBlock.class)) {
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), blockBuilder);
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
Position other = seg.getPosition();
|
||||
builder.putBits(14, seg.getIndex());
|
||||
builder.putBits(1, updateRequired ? 1 : 0);
|
||||
builder.putBits(5, other.getY() - npc.getY()); // these might be
|
||||
builder.putBits(5, other.getX() - npc.getX()); // the wrong way around
|
||||
builder.putBits(5, other.getY() - npc.getY());
|
||||
builder.putBits(5, other.getX() - npc.getX());
|
||||
builder.putBits(1, 0); // discard walking queue
|
||||
builder.putBits(13, seg.getNpcId());
|
||||
}
|
||||
@@ -88,21 +88,21 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
* Puts an animation block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder builder) {
|
||||
Animation animation = block.getAnimation();
|
||||
blockBuilder.put(DataType.SHORT, animation.getId());
|
||||
blockBuilder.put(DataType.BYTE, DataTransformation.SUBTRACT, animation.getDelay());
|
||||
builder.put(DataType.SHORT, animation.getId());
|
||||
builder.put(DataType.BYTE, DataTransformation.SUBTRACT, animation.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the blocks for the specified segment.
|
||||
*
|
||||
* @param segment The segment.
|
||||
* @param blockBuilder The block builder.
|
||||
* @param builder The block builder.
|
||||
*/
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder blockBuilder) {
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder builder) {
|
||||
SynchronizationBlockSet blockSet = segment.getBlockSet();
|
||||
if (blockSet.size() > 0) {
|
||||
int mask = 0;
|
||||
@@ -139,38 +139,38 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
mask |= 0x10;
|
||||
}
|
||||
|
||||
blockBuilder.put(DataType.BYTE, mask);
|
||||
builder.put(DataType.BYTE, mask);
|
||||
|
||||
if (blockSet.contains(TransformBlock.class)) {
|
||||
putTransformBlock(blockSet.get(TransformBlock.class), blockBuilder);
|
||||
putTransformBlock(blockSet.get(TransformBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(InteractingMobBlock.class)) {
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), blockBuilder);
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(HitUpdateBlock.class)) {
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), blockBuilder);
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(GraphicBlock.class)) {
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), blockBuilder);
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(ForceChatBlock.class)) {
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), blockBuilder);
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(TurnToPositionBlock.class)) {
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), blockBuilder);
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(AnimationBlock.class)) {
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), blockBuilder);
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), builder);
|
||||
}
|
||||
|
||||
if (blockSet.contains(SecondaryHitUpdateBlock.class)) {
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), blockBuilder);
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,12 +189,12 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
* Puts a graphic block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putGraphicBlock(GraphicBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putGraphicBlock(GraphicBlock block, GamePacketBuilder builder) {
|
||||
Graphic graphic = block.getGraphic();
|
||||
blockBuilder.put(DataType.SHORT, graphic.getId());
|
||||
blockBuilder.put(DataType.INT, DataOrder.MIDDLE, graphic.getDelay());
|
||||
builder.put(DataType.SHORT, graphic.getId());
|
||||
builder.put(DataType.INT, DataOrder.MIDDLE, graphic.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,12 +289,12 @@ public final class NpcSynchronizationEventEncoder extends EventEncoder<NpcSynchr
|
||||
* Puts a turn to position block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putTurnToPositionBlock(TurnToPositionBlock block, GamePacketBuilder blockBuilder) {
|
||||
Position pos = block.getPosition();
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD, pos.getX() * 2 + 1);
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, pos.getY() * 2 + 1);
|
||||
private void putTurnToPositionBlock(TurnToPositionBlock block, GamePacketBuilder builder) {
|
||||
Position position = block.getPosition();
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD, position.getX() * 2 + 1);
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, position.getY() * 2 + 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,27 +101,27 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
* Puts an Animation block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder builder) {
|
||||
Animation animation = block.getAnimation();
|
||||
blockBuilder.put(DataType.SHORT, animation.getId());
|
||||
blockBuilder.put(DataType.BYTE, DataTransformation.ADD, animation.getDelay());
|
||||
builder.put(DataType.SHORT, animation.getId());
|
||||
builder.put(DataType.BYTE, DataTransformation.ADD, animation.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an Appearance block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putAppearanceBlock(AppearanceBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putAppearanceBlock(AppearanceBlock block, GamePacketBuilder builder) {
|
||||
Appearance appearance = block.getAppearance();
|
||||
GamePacketBuilder playerProperties = new GamePacketBuilder();
|
||||
|
||||
playerProperties.put(DataType.BYTE, appearance.getGender().toInteger());
|
||||
playerProperties.put(DataType.BYTE, block.getHeadIcon()); // skull icon
|
||||
playerProperties.put(DataType.BYTE, block.getPrayerIcon()); // prayer icon
|
||||
playerProperties.put(DataType.BYTE, block.isSkulled() ? 1 : 0);
|
||||
playerProperties.put(DataType.BYTE, block.getHeadIcon());
|
||||
|
||||
if (block.appearingAsNpc()) {
|
||||
playerProperties.put(DataType.BYTE, 255);
|
||||
@@ -220,17 +220,17 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
playerProperties.put(DataType.BYTE, block.getCombatLevel());
|
||||
playerProperties.put(DataType.SHORT, block.getSkillLevel());
|
||||
|
||||
blockBuilder.put(DataType.BYTE, playerProperties.getLength());
|
||||
blockBuilder.putRawBuilderReverse(playerProperties);
|
||||
builder.put(DataType.BYTE, playerProperties.getLength());
|
||||
builder.putRawBuilderReverse(playerProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the blocks for the specified segment.
|
||||
*
|
||||
* @param segment The segment.
|
||||
* @param blockBuilder The block builder.
|
||||
* @param builder The block builder.
|
||||
*/
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder blockBuilder) {
|
||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder builder) {
|
||||
SynchronizationBlockSet blockSet = segment.getBlockSet();
|
||||
if (blockSet.size() > 0) {
|
||||
int mask = 0;
|
||||
@@ -268,42 +268,41 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
|
||||
if (mask >= 0x100) {
|
||||
mask |= 0x20;
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, mask);
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, mask);
|
||||
} else {
|
||||
blockBuilder.put(DataType.BYTE, mask);
|
||||
builder.put(DataType.BYTE, mask);
|
||||
}
|
||||
|
||||
if (blockSet.contains(AnimationBlock.class)) {
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), blockBuilder);
|
||||
putAnimationBlock(blockSet.get(AnimationBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(ForceChatBlock.class)) {
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), blockBuilder);
|
||||
putForceChatBlock(blockSet.get(ForceChatBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(ForceMovementBlock.class)) {
|
||||
putForceMovementBlock(blockSet.get(ForceMovementBlock.class), blockBuilder);
|
||||
putForceMovementBlock(blockSet.get(ForceMovementBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(InteractingMobBlock.class)) {
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), blockBuilder);
|
||||
putInteractingMobBlock(blockSet.get(InteractingMobBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(TurnToPositionBlock.class)) {
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), blockBuilder);
|
||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(GraphicBlock.class)) {
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), blockBuilder);
|
||||
putGraphicBlock(blockSet.get(GraphicBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(AppearanceBlock.class)) {
|
||||
putAppearanceBlock(blockSet.get(AppearanceBlock.class), blockBuilder);
|
||||
putAppearanceBlock(blockSet.get(AppearanceBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(SecondaryHitUpdateBlock.class)) {
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), blockBuilder);
|
||||
putSecondHitUpdateBlock(blockSet.get(SecondaryHitUpdateBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(ChatBlock.class)) {
|
||||
putChatBlock(blockSet.get(ChatBlock.class), blockBuilder);
|
||||
putChatBlock(blockSet.get(ChatBlock.class), builder);
|
||||
}
|
||||
if (blockSet.contains(HitUpdateBlock.class)) {
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), blockBuilder);
|
||||
putHitUpdateBlock(blockSet.get(HitUpdateBlock.class), builder);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,14 +310,14 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
* Puts a chat block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putChatBlock(ChatBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putChatBlock(ChatBlock block, GamePacketBuilder builder) {
|
||||
byte[] bytes = block.getCompressedMessage();
|
||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, block.getTextEffects() << 8 | block.getTextColor());
|
||||
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE, block.getPrivilegeLevel().toInteger());
|
||||
blockBuilder.put(DataType.BYTE, DataTransformation.ADD, bytes.length);
|
||||
blockBuilder.putBytes(DataTransformation.ADD, bytes);
|
||||
builder.put(DataType.SHORT, DataOrder.LITTLE, block.getTextEffects() << 8 | block.getTextColor());
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, block.getPrivilegeLevel().toInteger());
|
||||
builder.put(DataType.BYTE, DataTransformation.ADD, bytes.length);
|
||||
builder.putBytes(DataTransformation.ADD, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,12 +350,12 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
* Puts a graphic block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putGraphicBlock(GraphicBlock block, GamePacketBuilder blockBuilder) {
|
||||
private void putGraphicBlock(GraphicBlock block, GamePacketBuilder builder) {
|
||||
Graphic graphic = block.getGraphic();
|
||||
blockBuilder.put(DataType.SHORT, DataTransformation.ADD, graphic.getId());
|
||||
blockBuilder.put(DataType.INT, DataOrder.MIDDLE, graphic.getHeight() << 16 & 0xFFFF0000 | graphic.getDelay()
|
||||
builder.put(DataType.SHORT, DataTransformation.ADD, graphic.getId());
|
||||
builder.put(DataType.INT, DataOrder.MIDDLE, graphic.getHeight() << 16 & 0xFFFF0000 | graphic.getDelay()
|
||||
& 0x0000FFFF);
|
||||
}
|
||||
|
||||
@@ -452,12 +451,12 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
||||
* Puts a turn to position block into the specified builder.
|
||||
*
|
||||
* @param block The block.
|
||||
* @param blockBuilder The builder.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putTurnToPositionBlock(TurnToPositionBlock block, GamePacketBuilder blockBuilder) {
|
||||
Position pos = block.getPosition();
|
||||
blockBuilder.put(DataType.SHORT, pos.getX() * 2 + 1);
|
||||
blockBuilder.put(DataType.SHORT, pos.getY() * 2 + 1);
|
||||
private void putTurnToPositionBlock(TurnToPositionBlock block, GamePacketBuilder builder) {
|
||||
Position position = block.getPosition();
|
||||
builder.put(DataType.SHORT, position.getX() * 2 + 1);
|
||||
builder.put(DataType.SHORT, position.getY() * 2 + 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,4 +43,4 @@ public final class UpdateItemsEventEncoder extends EventEncoder<UpdateItemsEvent
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user