Massive varp/varbit related refactoring + new client command

This commit is contained in:
ceikry 2021-08-09 13:20:07 -05:00
parent 3c5c702e7e
commit aa6bf95006
2 changed files with 17 additions and 2 deletions

View file

@ -7,8 +7,14 @@ import core.net.packet.context.VarbitContext;
public class Varbit implements OutgoingPacket<VarbitContext> { public class Varbit implements OutgoingPacket<VarbitContext> {
@Override @Override
public void send(VarbitContext varbitContext) { public void send(VarbitContext varbitContext) {
IoBuffer buffer = new IoBuffer(37); IoBuffer buffer;
buffer.put((byte) varbitContext.value); if(varbitContext.value > 255){
buffer = new IoBuffer(84);
buffer.putLEInt((128 | varbitContext.value) & 255);
} else {
buffer = new IoBuffer(37);
buffer.put((byte) 128 | varbitContext.value);
}
buffer.putLEShort(varbitContext.varbitId); buffer.putLEShort(varbitContext.varbitId);
varbitContext.getPlayer().getSession().write(buffer); varbitContext.getPlayer().getSession().write(buffer);
} }

View file

@ -261,6 +261,15 @@ class VisualCommand : CommandPlugin() {
PacketRepository.send(Varbit::class.java, VarbitContext(player, value, val2)) PacketRepository.send(Varbit::class.java, VarbitContext(player, value, val2))
return true return true
} }
"setbits" -> {
args ?: return false
val start = toInteger(args[1]!!)
val end = toInteger(args[2]!!)
val value = toInteger(args[3]!!)
for(i in start until end){
player?.varpManager?.setVarbit(i, value)
}
}
"loop_anim_on_i" -> { "loop_anim_on_i" -> {
var anim = toInteger(args!![1]!!) var anim = toInteger(args!![1]!!)
ContentAPI.submitWorldPulse(object : Pulse(3){ ContentAPI.submitWorldPulse(object : Pulse(3){