RuneHive-Game
Loading...
Searching...
No Matches
SendMapRegion.java
Go to the documentation of this file.
1package com.runehive.net.packet.out;
2
3import com.runehive.net.codec.ByteModification;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.net.packet.OutgoingPacket;
6
7public class SendMapRegion extends OutgoingPacket {
8
9 public SendMapRegion() {
10 super(73, 4);
11 }
12
13 @Override
14 public boolean encode(Player player) {
15 player.lastPosition = player.getPosition().copy();
16
17 // 317-style region in CHUNKS (8x8)
18 int regionX = (player.getPosition().getX() >> 3);
19 int regionY = (player.getPosition().getY() >> 3);
20
21 // The client's scene base (chunk coords) is region - 6
22 int sceneBaseChunkX = regionX - 6;
23 int sceneBaseChunkY = regionY - 6;
24
25 // Persist the exact base the client will use
26 player.setSceneBaseChunks(sceneBaseChunkX, sceneBaseChunkY);
27
28 System.out.printf("[MapRegion] sceneBaseChunks=(%d,%d) tiles=(%d,%d)%n",
29 sceneBaseChunkX, sceneBaseChunkY,
30 sceneBaseChunkX * 8, sceneBaseChunkY * 8
31 );
32
33 builder.writeShort(player.getPosition().getChunkX() + 6, ByteModification.ADD)
34 .writeShort(player.getPosition().getChunkY() + 6);
35 return true;
36 }
37
38}
This class represents a character controlled by a player.
Definition Player.java:125
void setSceneBaseChunks(int chunkX, int chunkY)
Definition Player.java:966
int getChunkX()
Gets the chunk x coordinate.
Definition Position.java:76
int getChunkY()
Gets the chunk y coordinate.
Definition Position.java:81
Position copy()
Creates a deep copy of this location.
OutgoingPacket(int opcode, int capacity)
Represents RuneScape's custom value types.
ADD
Adds 128 to the value when written, subtracts 128 from the rarity when read.