Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void sendDynamicGameScene(boolean sendLswp) {
- OutputStream stream = new OutputStream();
- stream.writePacketVarShort(player, 173);
- if (sendLswp) // exists on newer protocol, sends all player encoded
- // region ids, afterwards new pupdate protocol is
- // regionbased
- player.getLocalPlayerUpdate().init(stream);
- int middleChunkX = player.getChunkX();
- int middleChunkY = player.getChunkY();
- stream.writeByte128(2);
- stream.writeShort(middleChunkY);
- stream.writeByte128(player.getMapSize());
- stream.writeShortLE128(middleChunkX);
- stream.writeByte(player.isForceNextMapLoadRefresh() ? 1 : 0);
- stream.write128Byte((1 << 65 + 1) + 1);// new on 876 client
- // supporting npcs
- stream.initBitAccess();
- /*
- * cene length in chunks. scene tiles length / 16, 8 is a chunk size, 16
- * because the code behind its signed and goes from middle-length to
- * middle+length
- */
- int sceneLength = Settings.MAP_SIZES[player.getMapSize()] >> 4;
- // the regionids(maps files) that will be used to load this scene
- int[] regionIds = new int[4 * sceneLength * sceneLength];
- int newRegionIdsCount = 0;
- for (int plane = 0; plane < 4; plane++) {
- for (int realChunkX = (middleChunkX - sceneLength); realChunkX <= ((middleChunkX
- + sceneLength)); realChunkX++) {
- int regionX = realChunkX / 8;
- y: for (int realChunkY = (middleChunkY - sceneLength); realChunkY <= ((middleChunkY
- + sceneLength)); realChunkY++) {
- int regionY = realChunkY / 8;
- // rcx / 8 = rx, rcy / 8 = ry, regionid is encoded region x
- // and y
- int regionId = (regionX << 8) + regionY;
- Region region = World.getRegions().get(regionId);
- int newChunkX;
- int newChunkY;
- int newPlane;
- int rotation;
- if (region instanceof DynamicRegion) { // generated map
- DynamicRegion dynamicRegion = (DynamicRegion) region;
- int[] pallete = dynamicRegion.getRegionCoords()[plane][realChunkX - (regionX * 8)][realChunkY
- - (regionY * 8)];
- newChunkX = pallete[0];
- newChunkY = pallete[1];
- newPlane = pallete[2];
- rotation = pallete[3];
- } else { // real map
- newChunkX = realChunkX;
- newChunkY = realChunkY;
- newPlane = plane;
- rotation = 0;// no rotation
- }
- // invalid chunk, not built chunk
- if (newChunkX == 0 || newChunkY == 0)
- stream.writeBits(1, 0);
- else {
- stream.writeBits(1, 1);
- // chunk encoding = (x << 14) | (y << 3) | (plane <<
- // 24), theres addition of two more bits for rotation
- stream.writeBits(26, (rotation << 1) | (newPlane << 24) | (newChunkX << 14) | (newChunkY << 3));
- int newRegionId = (((newChunkX / 8) << 8) + (newChunkY / 8));
- for (int index = 0; index < newRegionIdsCount; index++)
- if (regionIds[index] == newRegionId)
- continue y;
- regionIds[newRegionIdsCount++] = newRegionId;
- }
- }
- }
- }
- stream.finishBitAccess();
- stream.writeByte(newRegionIdsCount);
- /*
- * for (int index = 0; index < newRegionIdsCount; index++) { int[] xteas
- * = MapArchiveKeys.getMapKeys(regionIds[index]); if (xteas == null)
- * xteas = new int[4]; for (int keyIndex = 0; keyIndex < 4; keyIndex++)
- * stream.writeInt(xteas[keyIndex]); }
- */
- stream.endPacketVarShort();
- session.write(stream);
- }
- public void sendIComponentInputInteger(int interfaceId, int componentId, int length) {
- player.getPackets().sendCSVarInteger(2235, (interfaceId << 16 | componentId));
- player.getPackets().sendCSVarInteger(2236, 7);
- player.getPackets().sendCSVarInteger(2237, length);
- }
- public void sendIComponentInputText(int interfaceId, int componentId, int length) {
- player.getPackets().sendCSVarInteger(2235, (interfaceId << 16 | componentId));
- player.getPackets().sendCSVarInteger(2236, 9);
- player.getPackets().sendCSVarInteger(2237, length);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement