auracore/src/main/java/dev/tilera/auracore/network/AuraPacket.java

68 lines
1.7 KiB
Java
Raw Normal View History

2022-11-19 12:16:58 +01:00
package dev.tilera.auracore.network;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import dev.tilera.auracore.api.AuraNode;
import io.netty.buffer.ByteBuf;
public class AuraPacket implements IMessage {
public int key;
public double x;
public double y;
public double z;
public short level;
public short base;
2022-11-20 19:18:25 +01:00
public short taint;
2022-11-19 12:16:58 +01:00
public int flux;
public boolean lock;
public byte type;
2023-01-21 22:58:54 +01:00
public boolean virtual;
2022-11-19 12:16:58 +01:00
public AuraPacket() {}
public AuraPacket(AuraNode node) {
this.key = node.key;
this.x = node.xPos;
this.y = node.yPos;
this.z = node.zPos;
this.level = node.level;
this.base = node.baseLevel;
2022-11-20 19:18:25 +01:00
this.taint = node.taint;
2022-11-19 12:16:58 +01:00
this.flux = node.flux.visSize();
this.lock = node.locked;
this.type = (byte) node.type.ordinal();
2023-01-21 22:58:54 +01:00
this.virtual = node.isVirtual;
2022-11-19 12:16:58 +01:00
}
@Override
public void fromBytes(ByteBuf buf) {
this.key = buf.readInt();
this.x = buf.readDouble();
this.y = buf.readDouble();
this.z = buf.readDouble();
this.level = buf.readShort();
this.base = buf.readShort();
2022-11-20 19:18:25 +01:00
this.taint = buf.readShort();
2022-11-19 12:16:58 +01:00
this.flux = buf.readInt();
this.lock = buf.readBoolean();
this.type = buf.readByte();
2023-01-21 22:58:54 +01:00
this.virtual = buf.readBoolean();
2022-11-19 12:16:58 +01:00
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(key);
buf.writeDouble(x);
buf.writeDouble(y);
buf.writeDouble(z);
buf.writeShort(level);
buf.writeShort(base);
2022-11-20 19:18:25 +01:00
buf.writeShort(taint);
2022-11-19 12:16:58 +01:00
buf.writeInt(flux);
buf.writeBoolean(lock);
buf.writeByte(type);
2023-01-21 22:58:54 +01:00
buf.writeBoolean(virtual);
2022-11-19 12:16:58 +01:00
}
}