public variable to enum in BossBarPacket
This commit is contained in:
@@ -4,9 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package mc.core.network.proto_1_12_2.packets;
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import mc.core.network.NetOutputStream;
|
import mc.core.network.NetOutputStream;
|
||||||
import mc.core.network.SCPacket;
|
import mc.core.network.SCPacket;
|
||||||
import mc.core.network.proto_1_12_2.serializers.TextMapper;
|
import mc.core.network.proto_1_12_2.serializers.TextMapper;
|
||||||
@@ -17,33 +15,58 @@ import java.util.UUID;
|
|||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
public class BossBarPacket implements SCPacket {
|
public class BossBarPacket implements SCPacket {
|
||||||
public static final int ACTION_ADD = 0,
|
@RequiredArgsConstructor
|
||||||
ACTION_REMOVE = 1,
|
public enum Action {
|
||||||
ACTION_UPDATE_HEALTH = 2,
|
ADD(0),
|
||||||
ACTION_UPDATE_TITLE = 3,
|
REMOVE(1),
|
||||||
ACTION_UPDATE_STYLE = 4,
|
UPDATE_HEALTH(2),
|
||||||
ACTION_UPDATE_FLAGS = 5;
|
UPDATE_TITLE(3),
|
||||||
|
UPDATE_STYLE(4),
|
||||||
|
UPDATE_FLAGS(5);
|
||||||
|
|
||||||
public static final int COLOR_PINK = 0,
|
@Getter
|
||||||
COLOR_BLUE = 1,
|
private final int id;
|
||||||
COLOR_RED = 2,
|
}
|
||||||
COLOR_GREEN = 3,
|
|
||||||
COLOR_YELLOW = 4,
|
|
||||||
COLOR_PURPLE = 5,
|
|
||||||
COLOR_WHITE = 6;
|
|
||||||
|
|
||||||
public static final int DIVISION_NO = 0,
|
@RequiredArgsConstructor
|
||||||
DIVISION_0 = DIVISION_NO,
|
public enum Color {
|
||||||
DIVISION_6 = 1,
|
PINK(0),
|
||||||
DIVISION_10 = 2,
|
BLUE(1),
|
||||||
DIVISION_12 = 3,
|
RED(2),
|
||||||
DIVISION_20 = 4;
|
GREEN(3),
|
||||||
|
YELLOW(4),
|
||||||
|
PURPLE(5),
|
||||||
|
WHITE(5);
|
||||||
|
|
||||||
public static final byte FLAG_NO = 0x00,
|
@Getter
|
||||||
FLAG_DAKR_SKY = 0x01,
|
private final int id;
|
||||||
FLAG_DRAGON_BAR = 0x02;
|
}
|
||||||
|
|
||||||
@Data
|
@RequiredArgsConstructor
|
||||||
|
public enum Division {
|
||||||
|
NO(0),
|
||||||
|
_0(0),
|
||||||
|
_6(1),
|
||||||
|
_10(2),
|
||||||
|
_12(3),
|
||||||
|
_20(4);
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final int id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum Flag {
|
||||||
|
NO(0x00),
|
||||||
|
DAKR_SKY(0x01),
|
||||||
|
DRAGON_BAR(0x02);
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final int id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public static class BarData {
|
public static class BarData {
|
||||||
private Text title;
|
private Text title;
|
||||||
/*
|
/*
|
||||||
@@ -53,39 +76,39 @@ public class BossBarPacket implements SCPacket {
|
|||||||
* (https://i.johni0702.de/nA.png)
|
* (https://i.johni0702.de/nA.png)
|
||||||
*/
|
*/
|
||||||
private float health;
|
private float health;
|
||||||
private int color;
|
private Color color;
|
||||||
private int division;
|
private Division division;
|
||||||
private byte flags;
|
private Flag flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID uuid; // Unique ID for this bar
|
private UUID uuid; // Unique ID for this bar
|
||||||
private int action;
|
private Action action;
|
||||||
private BarData barData;
|
private BarData barData;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSelf(NetOutputStream netStream) {
|
public void writeSelf(NetOutputStream netStream) {
|
||||||
netStream.writeUUID(uuid);
|
netStream.writeUUID(uuid);
|
||||||
netStream.writeVarInt(action);
|
netStream.writeVarInt(action.id);
|
||||||
|
|
||||||
if (action == ACTION_REMOVE) {
|
if (action == Action.REMOVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == ACTION_ADD || action == ACTION_UPDATE_TITLE) {
|
if (action == Action.ADD || action == Action.UPDATE_TITLE) {
|
||||||
netStream.writeString(TextMapper.getInstance().mapping(barData.title));
|
netStream.writeString(TextMapper.getInstance().mapping(barData.title));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == ACTION_ADD || action == ACTION_UPDATE_HEALTH) {
|
if (action == Action.ADD || action == Action.UPDATE_HEALTH) {
|
||||||
netStream.writeFloat(barData.health);
|
netStream.writeFloat(barData.health);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == ACTION_ADD || action == ACTION_UPDATE_STYLE) {
|
if (action == Action.ADD || action == Action.UPDATE_STYLE) {
|
||||||
netStream.writeVarInt(barData.color);
|
netStream.writeVarInt(barData.color.id);
|
||||||
netStream.writeVarInt(barData.division);
|
netStream.writeVarInt(barData.division.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == ACTION_ADD || action == ACTION_UPDATE_FLAGS) {
|
if (action == Action.ADD || action == Action.UPDATE_FLAGS) {
|
||||||
netStream.writeUnsignedByte(barData.flags);
|
netStream.writeUnsignedByte(barData.flags.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,12 +122,12 @@ public class LoginHandler extends AbstractStateHandler implements LoginStateHand
|
|||||||
BossBarPacket pkt7 = new BossBarPacket();
|
BossBarPacket pkt7 = new BossBarPacket();
|
||||||
BossBarPacket.BarData barData = new BossBarPacket.BarData();
|
BossBarPacket.BarData barData = new BossBarPacket.BarData();
|
||||||
barData.setTitle(Text.of(TextColor.GREEN, TextStyle.BOLD, "FORWOLK"));
|
barData.setTitle(Text.of(TextColor.GREEN, TextStyle.BOLD, "FORWOLK"));
|
||||||
barData.setColor(BossBarPacket.COLOR_WHITE);
|
barData.setColor(BossBarPacket.Color.WHITE);
|
||||||
barData.setDivision(BossBarPacket.DIVISION_12);
|
barData.setDivision(BossBarPacket.Division._12);
|
||||||
barData.setHealth(1.0f);
|
barData.setHealth(1.0f);
|
||||||
barData.setFlags(BossBarPacket.FLAG_NO);
|
barData.setFlags(BossBarPacket.Flag.NO);
|
||||||
pkt7.setUuid(UUID.randomUUID());
|
pkt7.setUuid(UUID.randomUUID());
|
||||||
pkt7.setAction(BossBarPacket.ACTION_ADD);
|
pkt7.setAction(BossBarPacket.Action.ADD);
|
||||||
pkt7.setBarData(barData);
|
pkt7.setBarData(barData);
|
||||||
channel.writeAndFlush(pkt7);
|
channel.writeAndFlush(pkt7);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user