PDA

View Full Version : 650 Packets Released



Cjay0091
June 18th, 2011, 16:59
Enjoy and good luck with your 650 server(s). ;)

World List Packet Id : 130, Variable_Short


/**
* Sends the ping packet
*
* @return The action sender instance, for chaining.
*/
public ActionSender sendPingPacket() {
PacketBuilder builder = new PacketBuilder(59);
player.write(builder.toPacket());
return this;
}


/**
* Sends the windowPane
*
* @param pane
* - The paneID
* @return The action sender instance, for chaining.
*/
private ActionSender sendWindowPane(int pane) {
player.write(new PacketBuilder(22).putByteC((byte) 0).putShort(pane)
.toPacket());
return this;
}


/**
* Sends the map region load command.
*
* @return The action sender instance, for chaining.
*/
public ActionSender sendMapRegion(boolean login) {
player.setLastKnownRegion(player.getLocation());
PacketBuilder pb = new PacketBuilder(20, Type.VARIABLE_SHORT);

int locHash = player.getLocation().getX() << 14
| player.getLocation().getY() & 0x3fff
| player.getLocation().getZ() << 28;
if (login) {
pb.startBitAccess();
pb.putBits(30, locHash);
for (int i = 1; i < 2048; i++) {
if (i != player.getIndex()) {
pb.putBits(18, World.getWorld().getLocHash()[i]);
}
}
pb.finishBitAccess();
}
pb.putByteC(player.getLocation().getZ());
pb.putShortA(player.getLocation().getRegionX());
pb.putLEShortA(player.getLocation().getRegionY());
pb.putByteC(0);
boolean forceSend = true;
if ((((player.getLocation().getRegionX() / 8) == 48) || ((player
.getLocation().getRegionX() / 8) == 49))
&& ((player.getLocation().getRegionY() / 8) == 48)) {
forceSend = false;
}
if (((player.getLocation().getRegionX() / 8) == 48)
&& ((player.getLocation().getRegionY() / 8) == 148)) {
forceSend = false;
}
for (int xCalc = (player.getLocation().getRegionX() - 6) / 8; xCalc <= ((player
.getLocation().getRegionX() + 6) / 8); xCalc++) {
for (int yCalc = (player.getLocation().getRegionY() - 6) / 8; yCalc <= ((player
.getLocation().getRegionY() + 6) / 8); yCalc++) {
int region = yCalc + (xCalc << 8); // 1786653352
int[] xtea = XteaHandler.getXtea(region);
if (xtea == null) {
xtea = new int[4];
for (int i = 0; i < 4; i++) {
xtea[i] = 0;
}
}
pb.putInt(xtea[0]);
pb.putInt(xtea[1]);
pb.putInt(xtea[2]);
pb.putInt(xtea[3]);
}
}
player.write(pb.toPacket());
return this;
}



public ActionSender sendSpecialString(String string, int childId) {
PacketBuilder bldr = new PacketBuilder(37, Type.VARIABLE);
bldr.putShortA(childId);
bldr.putJAGString(string);
return this;
}

MrConner
June 22nd, 2011, 03:33
Good job mate (y) useful stuff here for those who wish to make a #650 server!