29 lines
559 B
JavaScript
29 lines
559 B
JavaScript
import {Packet} from '@avocado/net';
|
|
|
|
export default class TraitUpdateVisiblePacket extends Packet {
|
|
|
|
static pack(packet) {
|
|
const data = packet.data[1];
|
|
data.opacity = Math.floor(data.opacity * 255);
|
|
return super.pack(packet);
|
|
}
|
|
|
|
static get schema() {
|
|
return {
|
|
...super.schema,
|
|
data: {
|
|
isVisible: 'bool',
|
|
opacity: 'uint8',
|
|
},
|
|
};
|
|
}
|
|
|
|
static unpack(packet) {
|
|
const unpacked = super.unpack(packet);
|
|
const {data} = unpacked;
|
|
data.opacity = data.opacity / 255;
|
|
return unpacked;
|
|
}
|
|
|
|
}
|