Added + handled varbit packet

This commit is contained in:
ceikry
2021-08-08 23:15:18 -05:00
parent 1fa8479ca2
commit 629df5adaf
6 changed files with 63 additions and 3 deletions
@@ -77,6 +77,7 @@ public final class PacketRepository {
OUTGOING_PACKETS.put(UpdateRandomFile.class, new UpdateRandomFile()); //
OUTGOING_PACKETS.put(InstancedLocationUpdate.class, new InstancedLocationUpdate()); //
OUTGOING_PACKETS.put(CSConfigPacket.class, new CSConfigPacket()); //
OUTGOING_PACKETS.put(Varbit.class, new Varbit());
INCOMING_PACKETS.put(22, new ClientFocusPacket());
INCOMING_PACKETS.put(93, new PingPacketHandler());
INCOMING_PACKETS.put(44, new CommandPacket());
@@ -0,0 +1,22 @@
package core.net.packet.context;
import core.game.node.entity.player.Player;
import core.net.packet.Context;
public class VarbitContext implements Context {
Player player;
public int varbitId;
public int value;
public VarbitContext(Player player, int varbitId, int value){
this.player = player;
this.varbitId = varbitId;
this.value = value;
}
@Override
public Player getPlayer() {
return player;
}
}
@@ -266,6 +266,7 @@ public final class InteractionPacket implements IncomingPacket {
player.debug("dir=" + object.getDirection());
VarbitDefinition def = VarbitDefinition.forObjectID(SceneryDefinition.forId(objectId).getVarbitID());
player.debug("Varp ID=" + def.getConfigId() + " Offset=" + def.getBitShift() + " Size=" + def.getBitSize());
player.debug("Varbit: " + def.getId());
if (option.getHandler() != null) {
player.debug("Object handler: " + option.getHandler().getClass().getSimpleName());
}
@@ -0,0 +1,15 @@
package core.net.packet.out;
import core.net.packet.IoBuffer;
import core.net.packet.OutgoingPacket;
import core.net.packet.context.VarbitContext;
public class Varbit implements OutgoingPacket<VarbitContext> {
@Override
public void send(VarbitContext varbitContext) {
IoBuffer buffer = new IoBuffer(37);
buffer.put((byte) varbitContext.value);
buffer.putLEShort(varbitContext.varbitId);
varbitContext.getPlayer().getSession().write(buffer);
}
}