Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright © 2011 J.M. Linden
- // This program is free software; you can redistribute it and/or
- // modify it under the terms of the GNU General Public License
- // as published by the Free Software Foundation; either version 2
- // of the License, or (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this program; if not, write to the Free Software
- // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- package org.mike.gielinor.game.service.task;
- import static org.mike.gielinor.game.model.World.getWorld;
- import static org.mike.gielinor.game.model.container.Equipment.SLOT_BOOTS;
- import static org.mike.gielinor.game.model.container.Equipment.SLOT_CHEST;
- import static org.mike.gielinor.game.model.container.Equipment.SLOT_GLOVES;
- import static org.mike.gielinor.game.model.container.Equipment.SLOT_HELM;
- import static org.mike.gielinor.game.model.container.Equipment.SLOT_SHIELD;
- import static org.mike.gielinor.game.model.container.Equipment.isType;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.ANIMATION;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.APPEARANCE;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.CHAT;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.FACE_COORDINATE;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.FACE_ENTITY;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.FORCED_CHAT;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.FORCED_MOVEMENT;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.GRAPHICS;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.HIT;
- import static org.mike.gielinor.game.model.update.UpdateFlags.UpdateFlag.HIT_2;
- import static org.mike.gielinor.game.model.util.Skills.HITPOINTS;
- import static org.mike.gielinor.game.net.logic.GamePacket.PacketType.VARIABLE_SHORT;
- import java.util.Iterator;
- import java.util.List;
- import org.mike.core.service.task.Task;
- import org.mike.gielinor.game.model.Entity;
- import org.mike.gielinor.game.model.Item;
- import org.mike.gielinor.game.model.Player;
- import org.mike.gielinor.game.model.container.Container;
- import org.mike.gielinor.game.model.container.Equipment.EquipmentType;
- import org.mike.gielinor.game.model.update.UpdateAttributes;
- import org.mike.gielinor.game.model.update.UpdateFlags;
- import org.mike.gielinor.game.model.util.Animation;
- import org.mike.gielinor.game.model.util.Appearance;
- import org.mike.gielinor.game.model.util.ChatMessage;
- import org.mike.gielinor.game.model.util.Damage;
- import org.mike.gielinor.game.model.util.Graphic;
- import org.mike.gielinor.game.model.util.Location;
- import org.mike.gielinor.game.model.util.Skills;
- import org.mike.gielinor.game.net.logic.GamePacket;
- import org.mike.gielinor.game.net.logic.dispatch.GamePacketBuilder;
- import org.mike.gielinor.game.net.logic.dispatch.impl.MapRegionPacket;
- /**
- * A {@link Task} which deals with the updating of a specific {@link Player}.
- *
- * @author J.M. Linden
- *
- */
- public final class PlayerUpdateTask implements Task {
- /**
- * The {@link Player} to update.
- */
- private final Player player;
- /**
- * Creates a new {@link PlayerUpdateTask} for the specified {@link Player}.
- *
- * @param player
- * The {@link Player} to update.
- */
- public PlayerUpdateTask(final Player player) {
- this.player = player;
- }
- @Override
- public void execute() {
- System.out.println("Updating player...");
- // TODO player updating
- /*
- * If the map region changed send the new one. We do this immediately as
- * the client can begin loading it before the actual packet is received.
- */
- if (player.isMapRegionChanging()) {
- final Location loc = player.getLocation();
- player.setLastKnownRegion(loc);
- player.send(new MapRegionPacket(loc));
- }
- /*
- * The update block packet holds update blocks and is send after the
- * main packet.
- */
- final GamePacketBuilder updateBlock = new GamePacketBuilder();
- /*
- * The main packet is written in bits instead of bytes and holds
- * information about the local list, players to add and remove, movement
- * and which updates are required.
- */
- final GamePacketBuilder packet = new GamePacketBuilder(81,
- VARIABLE_SHORT);
- packet.startBitAccess();
- /*
- * Update this player.
- */
- updateThisPlayerMovement(packet);
- updatePlayer(updateBlock, player, false, true);
- final List<Player> localPlayers = player.getLocalPlayers();
- /*
- * Write the current size of the player list.
- */
- packet.writeBits(8, localPlayers.size());
- /*
- * Iterate through the world's player list.
- */
- for (Iterator<Player> it$ = localPlayers.iterator(); it$.hasNext();) {
- /*
- * Get the next player.
- */
- final Player otherPlayer = it$.next();
- /*
- * If the player should still be in our list.
- */
- if (getWorld().getPlayers().contains(otherPlayer)
- && !otherPlayer.isTeleporting()
- && otherPlayer.getLocation().isWithinDistance(
- player.getLocation())) {
- /*
- * Update the movement.
- */
- updatePlayerMovement(packet, otherPlayer);
- /*
- * Check if an update is required, and if so, send it.
- */
- if (otherPlayer.getUpdateAttributes().getFlags()
- .isUpdateRequired()) {
- updatePlayer(updateBlock, otherPlayer, false, false);
- }
- } else {
- /*
- * Otherwise, remove the player from the list.
- */
- it$.remove();
- /*
- * Tell the client to remove the player from the list.
- */
- packet.writeBits(1, 1);
- packet.writeBits(2, 3);
- }
- }
- /*
- * Loop through every player in the same region.
- */
- for (Player otherPlayer : getWorld().getRegionManager()
- .getLocalPlayers(player)) {
- /*
- * Check if there is room left in the local list.
- */
- if (localPlayers.size() >= 255) {
- /*
- * There is no more room left in the local list. We cannot add
- * more players, so we just ignore the extra ones. They will be
- * added as other players get removed.
- */
- break;
- }
- /*
- * If they should not be added ignore them.
- */
- if (otherPlayer == player || localPlayers.contains(otherPlayer)) {
- continue;
- }
- /*
- * Add the player to the local list if it is within distance.
- */
- localPlayers.add(otherPlayer);
- /*
- * Add the player in the packet.
- */
- addNewPlayer(packet, otherPlayer);
- /*
- * Update the player, forcing the appearance flag.
- */
- updatePlayer(updateBlock, otherPlayer, true, false);
- }
- /*
- * Check if the update block is not empty.
- */
- if (!updateBlock.isEmpty()) {
- /*
- * Write a magic id indicating an update block follows.
- */
- packet.writeBits(11, 2047);
- packet.finishBitAccess();
- /*
- * Add the update block at the end of this packet.
- */
- packet.writeBytes(updateBlock.toPacket().getPayload());
- } else {
- /*
- * Terminate the packet normally.
- */
- packet.finishBitAccess();
- }
- /*
- * Write the packet.
- */
- player.write(packet.toPacket());
- }
- /**
- * Updates the movement of a non-this {@link Player}.
- *
- * @param packet
- * The {@link GamePacketBuilder} to append the update to.
- * @param otherPlayer
- * The {@link Player} to get the update data from.
- */
- private void updatePlayerMovement(final GamePacketBuilder packet,
- final Player otherPlayer) {
- final UpdateAttributes otherAttributes = otherPlayer
- .getUpdateAttributes();
- /*
- * Check which type of movement took place.
- */
- if (otherAttributes.getPrimarySprite() == -1) {
- /*
- * If no movement did, check if an update is required.
- */
- if (otherAttributes.getFlags().isUpdateRequired()) {
- /*
- * Signify that an update happened.
- */
- packet.writeBits(1, 1);
- /*
- * Signify that there was no movement.
- */
- packet.writeBits(2, 0);
- } else {
- /*
- * Signify that nothing changed.
- */
- packet.writeBits(1, 0);
- }
- } else if (otherAttributes.getSecondarySprite() == -1) {
- /*
- * The player moved but didn't run. Signify that an update is
- * required.
- */
- packet.writeBits(1, 1);
- /*
- * Signify we moved one tile.
- */
- packet.writeBits(2, 1);
- /*
- * Write the primary sprite (i.e. walk direction).
- */
- packet.writeBits(3, otherAttributes.getPrimarySprite());
- /*
- * Write a flag indicating if a block update happened.
- */
- packet.writeBits(1,
- otherAttributes.getFlags().isUpdateRequired() ? 1 : 0);
- } else {
- /*
- * The player ran. Signify that an update happened.
- */
- packet.writeBits(1, 1);
- /*
- * Signify that we moved two tiles.
- */
- packet.writeBits(2, 2);
- /*
- * Write the primary sprite (i.e. walk direction).
- */
- packet.writeBits(3, otherAttributes.getPrimarySprite());
- /*
- * Write the secondary sprite (i.e. run direction).
- */
- packet.writeBits(3, otherAttributes.getSecondarySprite());
- /*
- * Write a flag indicating if a block update happened.
- */
- packet.writeBits(1,
- otherAttributes.getFlags().isUpdateRequired() ? 1 : 0);
- }
- }
- /**
- * Updates the movement of the {@link #player}.
- *
- * @param packet
- * The {@link GamePacketBuilder} to write the update data to.
- */
- private void updateThisPlayerMovement(final GamePacketBuilder packet) {
- /*
- * Check if the player is teleporting or their map region is changing.
- */
- if (player.isTeleporting() || player.isMapRegionChanging()) {
- /*
- * They are, so an update is required.
- */
- packet.writeBits(1, 1);
- /*
- * This value indicates the player teleported.
- */
- packet.writeBits(2, 3);
- final Location loc = player.getLocation();
- /*
- * This is the new player height.
- */
- packet.writeBits(2, loc.getZ());
- /*
- * This indicates that the client should discard the walking queue.
- */
- packet.writeBits(1, player.isTeleporting() ? 1 : 0);
- /*
- * This flag indicates if an update block is appended.
- */
- packet.writeBits(1, player.getUpdateAttributes().getFlags()
- .isUpdateRequired() ? 1 : 0);
- /*
- * These are the positions.
- */
- final Location lkr = player.getLastKnownRegion();
- packet.writeBits(7, loc.getLocalY(lkr));
- packet.writeBits(7, loc.getLocalX(lkr));
- } else {
- final UpdateAttributes attributes = player.getUpdateAttributes();
- /*
- * Otherwise, check if the player moved.
- */
- if (attributes.getPrimarySprite() == -1) {
- /*
- * The player didn't move. Check if an update is required.
- */
- if (attributes.getFlags().isUpdateRequired()) {
- /*
- * Signifies an update is required.
- */
- packet.writeBits(1, 1);
- /*
- * But signifies that we didn't move.
- */
- packet.writeBits(2, 0);
- } else {
- /*
- * Signifies that nothing changed.
- */
- packet.writeBits(1, 0);
- }
- } else {
- /*
- * Check if the player was running.
- */
- if (attributes.getSecondarySprite() == -1) {
- /*
- * The player walked, an update is required.
- */
- packet.writeBits(1, 1);
- /*
- * This indicates the player only walked.
- */
- packet.writeBits(2, 1);
- /*
- * This is the player's walking direction.
- */
- packet.writeBits(3, attributes.getPrimarySprite());
- /*
- * This flag indicates an update block is appended.
- */
- packet.writeBits(1, attributes.getFlags()
- .isUpdateRequired() ? 1 : 0);
- } else {
- /*
- * The player ran, so an update is required.
- */
- packet.writeBits(1, 1);
- /*
- * This indicates the player ran.
- */
- packet.writeBits(2, 2);
- /*
- * This is the walking direction.
- */
- packet.writeBits(3, attributes.getPrimarySprite());
- /*
- * And this is the running direction.
- */
- packet.writeBits(3, attributes.getSecondarySprite());
- /*
- * And this flag indicates an update block is appended.
- */
- packet.writeBits(1, attributes.getFlags()
- .isUpdateRequired() ? 1 : 0);
- }
- }
- }
- }
- /**
- * Appends the update of a newly added {@link Player}.
- *
- * @param packet
- * The {@link GamePacketBuilder} to write the update to.
- * @param otherPlayer
- * The {@link Player} to add.
- */
- private void addNewPlayer(final GamePacketBuilder packet,
- final Player otherPlayer) {
- /*
- * Write the player index.
- */
- packet.writeBits(11, otherPlayer.getIndex());
- /*
- * Write two flags here: the first indicates an update is required (this
- * is always true as we add the appearance after adding a player) and
- * the second to indicate we should discard client-side walk queues.
- */
- packet.writeBits(1, 1);
- packet.writeBits(1, 1);
- /*
- * Fetch the x and y coordinates.
- */
- final Location loc = player.getLocation(), otherLoc = otherPlayer
- .getLocation();
- /*
- * Write the x and y offsets.
- */
- packet.writeBits(5, otherLoc.getY() - loc.getY());
- packet.writeBits(5, otherLoc.getX() - loc.getX());
- }
- /**
- * Writes an update of the specified {@link Player} into the specified
- * {@link GamePacketBuilder}.
- *
- * @param packet
- * The {@link GamePacketBuilder} to write the update to.
- * @param otherPlayer
- * The {@link Player} to obtain the update data from.
- * @param forceAppearance
- * The force appearance flag.
- * @param noChat
- * Indicates chat should not be relayed to this player.
- */
- private void updatePlayer(final GamePacketBuilder packet,
- final Player otherPlayer, final boolean forceAppearance,
- final boolean noChat) {
- final UpdateAttributes otherAttributes = otherPlayer
- .getUpdateAttributes();
- /*
- * If no update is required and we don't have to force an appearance
- * update, don't write anything.
- */
- if (!otherAttributes.getFlags().isUpdateRequired() && !forceAppearance) {
- return;
- }
- /*
- * We can used the cached update block!
- */
- synchronized (otherPlayer) {
- if (otherPlayer.hasCachedUpdateBlock() && otherPlayer != player
- && !forceAppearance && !noChat) {
- packet.writeBytes(otherPlayer.getCachedUpdateBlock()
- .getPayload());
- return;
- }
- /*
- * We have to construct and cache our own block.
- */
- final GamePacketBuilder block = new GamePacketBuilder();
- /*
- * Calculate the bitmask.
- */
- int mask = 0;
- final UpdateFlags flags = otherAttributes.getFlags();
- final boolean forcedMovement = flags.get(FORCED_MOVEMENT);
- if (forcedMovement) {
- // TODO forced movement (mask 0x400)
- }
- final boolean graphics = flags.get(GRAPHICS);
- if (graphics) {
- mask |= 0x100;
- }
- final boolean animation = flags.get(ANIMATION);
- if (animation) {
- mask |= 0x8;
- }
- final boolean forcedChat = flags.get(FORCED_CHAT);
- if (forcedChat) {
- // TODO forced chat (mask 0x4)
- }
- final boolean chat = flags.get(CHAT);
- if (chat && !noChat) {
- mask |= 0x80;
- }
- final boolean faceEntity = flags.get(FACE_ENTITY);
- if (faceEntity) {
- mask |= 0x1;
- }
- final boolean appearance = flags.get(APPEARANCE);
- if (appearance) {
- mask |= 0x10;
- }
- final boolean faceCoordinate = flags.get(FACE_COORDINATE);
- if (faceCoordinate) {
- mask |= 0x2;
- }
- final boolean hit = flags.get(HIT);
- if (hit) {
- mask |= 0x20;
- }
- final boolean hit2 = flags.get(HIT_2);
- if (hit2) {
- mask |= 0x200;
- }
- /*
- * Check if the bitmask would overflow a byte.
- */
- if (mask >= 0x100) {
- /*
- * Write it as a short and indicate we have done so.
- */
- mask |= 0x40;
- block.writeByte(mask & 0xFF);
- block.writeByte(mask >> 8);
- } else {
- /*
- * Write it as a byte.
- */
- block.writeByte(mask);
- }
- /*
- * Append the appropriate updates.
- */
- if (forcedMovement) {
- }
- if (graphics) {
- appendGraphicsUpdate(block, otherPlayer);
- }
- if (animation) {
- appendAnimationUpdate(block, otherPlayer);
- }
- if (forcedChat) {
- }
- if (chat && !noChat) {
- appendChatUpdate(block, otherPlayer);
- }
- if (faceEntity) {
- final Entity entity = otherPlayer.getInteractingEntity();
- block.writeLittleEndianShort(entity == null ? -1 : entity
- .getClientIndex());
- }
- if (appearance) {
- appendPlayerAppearanceUpdate(block, otherPlayer);
- }
- if (faceCoordinate) {
- appendPlayerFacingCoordinateUpdate(block, otherPlayer);
- }
- if (hit) {
- appendPlayerHitUpdate(block, otherPlayer);
- }
- if (hit2) {
- appendPlayerHit2Update(block, otherPlayer);
- }
- /*
- * Convert the block builder to a packet.
- */
- final GamePacket blockPacket = block.toPacket();
- /*
- * Now it is over, cache the block if we can.
- */
- if (otherPlayer != player && !forceAppearance && !noChat) {
- otherPlayer.setCachedUpdateBlock(blockPacket);
- }
- /*
- * And finally append the block at the end.
- */
- packet.writeBytes(blockPacket.getPayload());
- }
- }
- /**
- * Appends an update for a specific {@link Player}'s current {@link Graphic}
- * appearance.
- *
- * @param block
- * The {@link GamePacketBuilder block builder} to append the
- * update to.
- * @param otherPlayer
- * The {@link Player} that is playing the {@link Graphic}.
- */
- private void appendGraphicsUpdate(final GamePacketBuilder block,
- final Player otherPlayer) {
- final Graphic g = otherPlayer.getCurrentGraphic();
- block.writeLittleEndianShort(g.getId());
- block.writeInt((g.getHeight() << 16) | g.getDelay());
- }
- /**
- * Appends an update for a specific {@link Player}'s current
- * {@link Animation} appearance.
- *
- * @param block
- * The {@link GamePacketBuilder block builder} to append the
- * update to.
- * @param otherPlayer
- * The {@link Player} that is performing the {@link Animation}.
- */
- private void appendAnimationUpdate(final GamePacketBuilder block,
- final Player otherPlayer) {
- final Animation a = otherPlayer.getCurrentAnimation();
- block.writeLittleEndianShort(a.getId());
- block.writeByteNegated(a.getDelay());
- }
- /**
- * Appends an update for a specific {@link Player}'s current
- * {@link ChatMessage}.
- *
- * @param block
- * The {@link GamePacketBuilder block builder} to append the
- * update to.
- * @param otherPlayer
- * The {@link Player} that has said the {@link ChatMessage}.
- */
- private void appendChatUpdate(final GamePacketBuilder block,
- final Player otherPlayer) {
- final ChatMessage cm = otherPlayer.getCurrentChatMessage();
- final byte[] bytes = cm.getText();
- block.writeLittleEndianShort(((cm.getColor() & 0xFF) << 8)
- | (cm.getEffects() & 0xFF));
- block.writeByte(otherPlayer.getRights().toInteger());
- final int length = bytes.length;
- block.writeByteNegated(length);
- for (int ptr = length - 1; ptr >= 0; ptr--) {
- block.writeByte(bytes[ptr]);
- }
- }
- /**
- * Appends an update for a specific {@link Player}'s general appearance.
- *
- * @param block
- * The {@link GamePacketBuilder block builder} to append the
- * update to.
- * @param otherPlayer
- * The {@link Player} of which the appearance should be updated.
- */
- private void appendPlayerAppearanceUpdate(final GamePacketBuilder block,
- final Player otherPlayer) {
- final Appearance app = otherPlayer.getAppearance();
- final Container eq = otherPlayer.getEquipment();
- final GamePacketBuilder playerProps = new GamePacketBuilder();
- playerProps.writeByte(app.getGender()); // Gender
- playerProps.writeByte(0); // Skull icon
- for (int i = 0; i < 4; i++) {
- if (eq.isSlotUsed(i)) {
- playerProps.writeShort(0x200 + eq.get(i).getId());
- } else {
- playerProps.writeByte(0);
- }
- }
- playerProps.writeShort(eq.isSlotUsed(SLOT_CHEST) ? 0x200 + eq.get(
- SLOT_CHEST).getId() : 0x100 + app.getChest());
- if (eq.isSlotUsed(SLOT_SHIELD)) {
- playerProps.writeShort(0x200 + eq.get(SLOT_SHIELD).getId());
- } else {
- playerProps.writeByte(0);
- }
- final Item chest = eq.get(SLOT_CHEST);
- if (chest != null && isType(EquipmentType.PLATEBODY, chest)) {
- playerProps.writeShort(0x200 + chest.getId());
- } else {
- playerProps.writeShort(0x100 + app.getArms());
- }
- final Item helm = eq.get(SLOT_HELM);
- if (helm != null) {
- if (!isType(EquipmentType.FULL_HELM, helm)
- && !isType(EquipmentType.FULL_MASK, helm)) {
- playerProps.writeShort(0x100 + app.getHead());
- } else {
- playerProps.writeByte(0);
- }
- } else {
- playerProps.writeShort(0x100 + app.getHead());
- }
- playerProps.writeShort(eq.isSlotUsed(SLOT_GLOVES) ? 0x200 + eq.get(
- SLOT_GLOVES).getId() : 0x100 + app.getHands());
- playerProps.writeShort(eq.isSlotUsed(SLOT_BOOTS) ? 0x200 + eq.get(
- SLOT_BOOTS).getId() : 0x100 + app.getFeet());
- boolean fullHelm = false, hat = false;
- if (helm != null) {
- hat = isType(EquipmentType.HAT, helm);
- fullHelm = !isType(EquipmentType.FULL_HELM, helm);
- }
- if ((!hat && fullHelm) || app.getGender() == 1) {
- playerProps.writeByte(0);
- } else {
- playerProps.writeShort(0x100 + app.getBeard());
- }
- playerProps.writeByte(app.getHairColour())
- .writeByte(app.getTorsoColour()).writeByte(app.getLegColour())
- .writeByte(app.getFeetColour()).writeByte(app.getSkinColour());
- playerProps.writeShort(0x328); // stand
- playerProps.writeShort(0x337); // stand turn
- playerProps.writeShort(0x333); // walk
- playerProps.writeShort(0x334); // turn 180°
- playerProps.writeShort(0x335); // turn 90° cw
- playerProps.writeShort(0x336); // turn 90° ccw
- playerProps.writeShort(0x338); // run
- playerProps.writeLong(otherPlayer.getNameAsLong());
- playerProps.writeByte(otherPlayer.getSkills().getCombatLevel());
- playerProps.writeShort(0); // total level
- final GamePacket propsPacket = playerProps.toPacket();
- block.writeByteNegated(propsPacket.getLength());
- block.writeBytes(propsPacket.getPayload());
- }
- /**
- * Appends an update of the specified {@link Player}'s facing coordinate, to
- * the specified {@link GamePacketBuilder block builder}.
- *
- * @param block
- * The {@link GamePacketBuilder block builder} to append the
- * update to.
- * @param otherPlayer
- * The {@link Player} of which the facing coordinate should be
- * updated.
- */
- private void appendPlayerFacingCoordinateUpdate(
- final GamePacketBuilder block, final Player otherPlayer) {
- final Location loc = otherPlayer.getFaceLocation();
- if (loc == null) {
- block.writeLittleEndianShortAdded(0);
- block.writeLittleEndianShort(0);
- } else {
- block.writeLittleEndianShortAdded(loc.getX() * 2 + 1);
- block.writeLittleEndianShort(loc.getY() * 2 + 1);
- }
- }
- /**
- * Appends a first-hit update dealt to the specified {@link Player}, to the
- * specified {@link GamePacketBuilder block builder}.
- *
- * @param block
- * The {@link GamePacketBuilder block builder} to append the
- * update to.
- * @param otherPlayer
- * The {@link Player} that took the {@link Damage}.
- */
- private void appendPlayerHitUpdate(final GamePacketBuilder block,
- final Player otherPlayer) {
- final Damage dmg = otherPlayer.getDamage();
- block.writeByte(dmg.getHitDamage1()).writeByteAdded(dmg.getHitType1());
- final Skills s = otherPlayer.getSkills();
- block.writeByteNegated(s.getLevel(HITPOINTS)).writeByte(
- s.getLevelForExperience(HITPOINTS));
- }
- /**
- * Appends a second-hit update dealt to the specified {@link Player}, to the
- * specified {@link GamePacketBuilder block builder}.
- *
- * @param block
- * The {@link GamePacketBuilder block builder} to append the
- * update to.
- * @param otherPlayer
- * The {@link Player} that took the {@link Damage}.
- */
- private void appendPlayerHit2Update(final GamePacketBuilder block,
- final Player otherPlayer) {
- final Damage dmg = otherPlayer.getDamage();
- block.writeByte(dmg.getHitDamage2()).writeByteSubtracted(
- dmg.getHitDamage2());
- final Skills s = otherPlayer.getSkills();
- block.writeByte(s.getLevel(HITPOINTS)).writeByteNegated(
- s.getLevelForExperience(HITPOINTS));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement