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