28 lines
522 B
JavaScript
28 lines
522 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 data = super.unpack(packet);
|
|
data.opacity = data.opacity / 255;
|
|
return data;
|
|
}
|
|
|
|
}
|