Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void updateNPC(PacketBuilder packet, NPC npc) {
- /*
- * Calculate the mask.
- */
- int mask = 0;
- final UpdateFlags flags = npc.getUpdateFlags();
- if(flags.get(UpdateFlag.TRANSFORM)) {
- mask |= 0x1;
- }
- if(flags.get(UpdateFlag.FACE_ENTITY)) {
- mask |= 0x40;
- }
- if(flags.get(UpdateFlag.HIT)) {
- mask |= 0x80;
- }
- if(flags.get(UpdateFlag.GRAPHICS)) {
- mask |= 0x4;
- }
- if(flags.get(UpdateFlag.FORCED_CHAT)) {
- mask |= 0x20;
- }
- if(flags.get(UpdateFlag.FACE_COORDINATE)) {
- mask |= 0x8;
- }
- if(flags.get(UpdateFlag.ANIMATION)) {
- mask |= 0x2;
- }
- if(flags.get(UpdateFlag.HIT_2)) {
- mask |= 0x10;
- }
- /*
- * And write the mask.
- */
- packet.put((byte) mask);
- if(flags.get(UpdateFlag.TRANSFORM)) {
- //putShortA(transformId)
- }
- if(flags.get(UpdateFlag.FACE_ENTITY)) {
- Entity entity = npc.getInteractingEntity();
- packet.putLEShort(entity == null ? -1 : entity.getClientIndex());
- }
- if(flags.get(UpdateFlag.HIT)) {
- //UByteA - hit
- //UByteA - hitType
- //UByte -
- //UByteS -
- }
- if(flags.get(UpdateFlag.GRAPHICS)) {
- packet.putShort(npc.getCurrentGraphic().getId());
- packet.putInt2(npc.getCurrentGraphic().getDelay());
- }
- if(flags.get(UpdateFlag.FORCED_CHAT)) {
- //putString
- }
- if(flags.get(UpdateFlag.FACE_COORDINATE)) {
- Location loc = npc.getFaceLocation();
- if(loc == null) {
- packet.putLEShort(0);
- packet.putLEShort(0);
- } else {
- packet.putLEShortA(loc.getX() * 2 + 1);
- packet.putLEShort(loc.getY() * 2 + 1);
- }
- }
- if(flags.get(UpdateFlag.ANIMATION)) {
- packet.putShort(npc.getCurrentAnimation().getId());
- packet.putByteS((byte) npc.getCurrentAnimation().getDelay());
- }
- if(flags.get(UpdateFlag.HIT_2)) {
- //UByteS - hit
- //UByteS - hitType
- //UByte -
- //UByteC -
- }
- }
Add Comment
Please, Sign In to add comment