mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
23w51a
This commit is contained in:
parent
eacfb2d037
commit
8bb3aadb88
11 changed files with 97 additions and 58 deletions
|
@ -88,7 +88,7 @@ lombok {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.github.steveice10"
|
group = "com.github.steveice10"
|
||||||
version = "1.20.4-2-SNAPSHOT"
|
version = "1.20.5-SNAPSHOT"
|
||||||
description = "MCProtocolLib is a simple library for communicating with Minecraft clients and servers."
|
description = "MCProtocolLib is a simple library for communicating with Minecraft clients and servers."
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|
|
@ -212,9 +212,9 @@ public class MinecraftCodec {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final PacketCodec CODEC = PacketCodec.builder()
|
public static final PacketCodec CODEC = PacketCodec.builder()
|
||||||
.protocolVersion(765)
|
.protocolVersion((1 << 30) | 169)
|
||||||
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
|
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
|
||||||
.minecraftVersion("1.20.4")
|
.minecraftVersion("23w51a")
|
||||||
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
|
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
|
||||||
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
|
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,13 +22,7 @@ import com.github.steveice10.mc.protocol.data.game.chunk.palette.SingletonPalett
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
|
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.EntityEvent;
|
import com.github.steveice10.mc.protocol.data.game.entity.EntityEvent;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierOperation;
|
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierOperation;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.*;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.GlobalPos;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.SnifferState;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.VillagerData;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.BlockBreakStage;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.BlockBreakStage;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
|
@ -330,6 +324,14 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
this.writeEnum(buf, state);
|
this.writeEnum(buf, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArmadilloState readArmadilloState(ByteBuf buf) {
|
||||||
|
return ArmadilloState.from(this.readVarInt(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeArmadilloState(ByteBuf buf, ArmadilloState state) {
|
||||||
|
this.writeEnum(buf, state);
|
||||||
|
}
|
||||||
|
|
||||||
private void writeEnum(ByteBuf buf, Enum<?> e) {
|
private void writeEnum(ByteBuf buf, Enum<?> e) {
|
||||||
this.writeVarInt(buf, e.ordinal());
|
this.writeVarInt(buf, e.ordinal());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.github.steveice10.mc.protocol.data.game.entity.attribute;
|
package com.github.steveice10.mc.protocol.data.game.entity.attribute;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -11,65 +13,67 @@ public interface AttributeType {
|
||||||
|
|
||||||
String getIdentifier();
|
String getIdentifier();
|
||||||
|
|
||||||
/**
|
int getId();
|
||||||
* Used when MCProtocolLib gets an attribute not in its built-in registry.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@EqualsAndHashCode
|
|
||||||
class Custom implements AttributeType {
|
|
||||||
private final String identifier;
|
|
||||||
|
|
||||||
public Custom(String identifier) {
|
// TODO: Reimplement once new format is finalized
|
||||||
this.identifier = identifier;
|
// /**
|
||||||
}
|
// * Used when MCProtocolLib gets an attribute not in its built-in registry.
|
||||||
|
// */
|
||||||
public String getIdentifier() {
|
// @Getter
|
||||||
return identifier;
|
// @EqualsAndHashCode
|
||||||
}
|
// class Custom implements AttributeType {
|
||||||
}
|
// private final String identifier;
|
||||||
|
//
|
||||||
|
// public Custom(String identifier) {
|
||||||
|
// this.identifier = identifier;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String getIdentifier() {
|
||||||
|
// return identifier;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
enum Builtin implements AttributeType {
|
enum Builtin implements AttributeType {
|
||||||
GENERIC_MAX_HEALTH("minecraft:generic.max_health", 20, 0, 1024),
|
|
||||||
GENERIC_FOLLOW_RANGE("minecraft:generic.follow_range", 32, 0, 2048),
|
|
||||||
GENERIC_KNOCKBACK_RESISTANCE("minecraft:generic.knockback_resistance", 0, 0, 1),
|
|
||||||
GENERIC_MOVEMENT_SPEED("minecraft:generic.movement_speed", 0.699999988079071, 0, 1024),
|
|
||||||
GENERIC_ATTACK_DAMAGE("minecraft:generic.attack_damage", 2, 0, 2048),
|
|
||||||
GENERIC_ATTACK_SPEED("minecraft:generic.attack_speed", 4, 0, 1024),
|
|
||||||
GENERIC_FLYING_SPEED("minecraft:generic.flying_speed", 0.4000000059604645, 0, 1024),
|
|
||||||
GENERIC_ARMOR("minecraft:generic.armor", 0, 0, 30),
|
GENERIC_ARMOR("minecraft:generic.armor", 0, 0, 30),
|
||||||
GENERIC_ARMOR_TOUGHNESS("minecraft:generic.armor_toughness", 0, 0, 20),
|
GENERIC_ARMOR_TOUGHNESS("minecraft:generic.armor_toughness", 0, 0, 20),
|
||||||
|
GENERIC_ATTACK_DAMAGE("minecraft:generic.attack_damage", 2, 0, 2048),
|
||||||
GENERIC_ATTACK_KNOCKBACK("minecraft:generic.attack_knockback", 0, 0, 5),
|
GENERIC_ATTACK_KNOCKBACK("minecraft:generic.attack_knockback", 0, 0, 5),
|
||||||
GENERIC_LUCK("minecraft:generic.luck", 0, -1024, 1024),
|
GENERIC_ATTACK_SPEED("minecraft:generic.attack_speed", 4, 0, 1024),
|
||||||
|
GENERIC_BLOCK_INTERACTION_RANGE("minecraft:generic.block_interaction_range", 4.5, 0, 64),
|
||||||
|
GENERIC_ENTITY_INTERACTION_RANGE("minecraft:generic.entity_interaction_range", 3, 0, 64),
|
||||||
|
GENERIC_FLYING_SPEED("minecraft:generic.flying_speed", 0.4F, 0, 1024),
|
||||||
|
GENERIC_FOLLOW_RANGE("minecraft:generic.follow_range", 32, 0, 2048),
|
||||||
HORSE_JUMP_STRENGTH("minecraft:horse.jump_strength", 0.7, 0, 2),
|
HORSE_JUMP_STRENGTH("minecraft:horse.jump_strength", 0.7, 0, 2),
|
||||||
ZOMBIE_SPAWN_REINFORCEMENTS("minecraft:zombie.spawn_reinforcements", 0, 0, 1);
|
GENERIC_KNOCKBACK_RESISTANCE("minecraft:generic.knockback_resistance", 0, 0, 1),
|
||||||
|
GENERIC_LUCK("minecraft:generic.luck", 0, -1024, 1024),
|
||||||
|
GENERIC_MAX_ABSORPTION("minecraft:generic.max_absorption", 0, 0, 2048),
|
||||||
|
GENERIC_MAX_HEALTH("minecraft:generic.max_health", 20, 0, 1024),
|
||||||
|
GENERIC_MOVEMENT_SPEED("minecraft:generic.movement_speed", 0.7F, 0, 1024),
|
||||||
|
GENERIC_SCALE("minecraft:generic.scale", 1, 0.0625, 16),
|
||||||
|
ZOMBIE_SPAWN_REINFORCEMENTS("minecraft:zombie.spawn_reinforcements", 0, 0, 1),
|
||||||
|
GENERIC_STEP_HEIGHT("minecraft:generic.step_height", 0.6, 0, 10);
|
||||||
|
|
||||||
private final String identifier;
|
private final String identifier;
|
||||||
private final double def;
|
private final double def;
|
||||||
private final double min;
|
private final double min;
|
||||||
private final double max;
|
private final double max;
|
||||||
|
|
||||||
public static final Map<String, AttributeType> BUILTIN = new HashMap<>();
|
public int getId() {
|
||||||
|
return this.ordinal();
|
||||||
static {
|
|
||||||
register(GENERIC_MAX_HEALTH);
|
|
||||||
register(GENERIC_FOLLOW_RANGE);
|
|
||||||
register(GENERIC_KNOCKBACK_RESISTANCE);
|
|
||||||
register(GENERIC_MOVEMENT_SPEED);
|
|
||||||
register(GENERIC_ATTACK_DAMAGE);
|
|
||||||
register(GENERIC_ATTACK_SPEED);
|
|
||||||
register(GENERIC_FLYING_SPEED);
|
|
||||||
register(GENERIC_ARMOR);
|
|
||||||
register(GENERIC_ARMOR_TOUGHNESS);
|
|
||||||
register(GENERIC_ATTACK_KNOCKBACK);
|
|
||||||
register(GENERIC_LUCK);
|
|
||||||
register(HORSE_JUMP_STRENGTH);
|
|
||||||
register(ZOMBIE_SPAWN_REINFORCEMENTS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(AttributeType attributeType) {
|
public static final Int2ObjectMap<AttributeType> BUILTIN = new Int2ObjectOpenHashMap<>();
|
||||||
BUILTIN.put(attributeType.getIdentifier(), attributeType);
|
|
||||||
|
public static AttributeType from(int id) {
|
||||||
|
return BUILTIN.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (Builtin attribute : values()) {
|
||||||
|
BUILTIN.put(attribute.ordinal(), attribute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.github.steveice10.mc.protocol.data.game.entity.metadata;
|
||||||
|
|
||||||
|
public enum ArmadilloState {
|
||||||
|
IDLE,
|
||||||
|
ROLLING,
|
||||||
|
SCARED;
|
||||||
|
|
||||||
|
private static final ArmadilloState[] VALUES = values();
|
||||||
|
|
||||||
|
public static ArmadilloState from(int id) {
|
||||||
|
return VALUES[id];
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,6 +54,7 @@ public class MetadataType<T> {
|
||||||
public static final MetadataType<Optional<GlobalPos>> OPTIONAL_GLOBAL_POS = new MetadataType<>(optionalReader(MinecraftCodecHelper::readGlobalPos), optionalWriter(MinecraftCodecHelper::writeGlobalPos), ObjectEntityMetadata::new);
|
public static final MetadataType<Optional<GlobalPos>> OPTIONAL_GLOBAL_POS = new MetadataType<>(optionalReader(MinecraftCodecHelper::readGlobalPos), optionalWriter(MinecraftCodecHelper::writeGlobalPos), ObjectEntityMetadata::new);
|
||||||
public static final MetadataType<PaintingType> PAINTING_VARIANT = new MetadataType<>(MinecraftCodecHelper::readPaintingType, MinecraftCodecHelper::writePaintingType, ObjectEntityMetadata::new);
|
public static final MetadataType<PaintingType> PAINTING_VARIANT = new MetadataType<>(MinecraftCodecHelper::readPaintingType, MinecraftCodecHelper::writePaintingType, ObjectEntityMetadata::new);
|
||||||
public static final MetadataType<SnifferState> SNIFFER_STATE = new MetadataType<>(MinecraftCodecHelper::readSnifferState, MinecraftCodecHelper::writeSnifferState, ObjectEntityMetadata::new);
|
public static final MetadataType<SnifferState> SNIFFER_STATE = new MetadataType<>(MinecraftCodecHelper::readSnifferState, MinecraftCodecHelper::writeSnifferState, ObjectEntityMetadata::new);
|
||||||
|
public static final MetadataType<ArmadilloState> ARMADILLO_STATE = new MetadataType<>(MinecraftCodecHelper::readArmadilloState, MinecraftCodecHelper::writeArmadilloState, ObjectEntityMetadata::new);
|
||||||
public static final MetadataType<Vector3f> VECTOR3 = new MetadataType<>(MinecraftCodecHelper::readRotation, MinecraftCodecHelper::writeRotation, ObjectEntityMetadata::new);
|
public static final MetadataType<Vector3f> VECTOR3 = new MetadataType<>(MinecraftCodecHelper::readRotation, MinecraftCodecHelper::writeRotation, ObjectEntityMetadata::new);
|
||||||
public static final MetadataType<Vector4f> QUATERNION = new MetadataType<>(MinecraftCodecHelper::readQuaternion, MinecraftCodecHelper::writeQuaternion, ObjectEntityMetadata::new);
|
public static final MetadataType<Vector4f> QUATERNION = new MetadataType<>(MinecraftCodecHelper::readQuaternion, MinecraftCodecHelper::writeQuaternion, ObjectEntityMetadata::new);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.github.steveice10.mc.protocol.data.game.entity.type;
|
||||||
public enum EntityType {
|
public enum EntityType {
|
||||||
ALLAY,
|
ALLAY,
|
||||||
AREA_EFFECT_CLOUD,
|
AREA_EFFECT_CLOUD,
|
||||||
|
ARMADILLO,
|
||||||
ARMOR_STAND,
|
ARMOR_STAND,
|
||||||
ARROW,
|
ARROW,
|
||||||
AXOLOTL,
|
AXOLOTL,
|
||||||
|
|
|
@ -61,6 +61,16 @@ public enum BuiltinSound implements Sound {
|
||||||
BLOCK_ANVIL_PLACE("block.anvil.place"),
|
BLOCK_ANVIL_PLACE("block.anvil.place"),
|
||||||
BLOCK_ANVIL_STEP("block.anvil.step"),
|
BLOCK_ANVIL_STEP("block.anvil.step"),
|
||||||
BLOCK_ANVIL_USE("block.anvil.use"),
|
BLOCK_ANVIL_USE("block.anvil.use"),
|
||||||
|
ENTITY_ARMADILLO_EAT("entity.armadillo.eat"),
|
||||||
|
ENTITY_ARMADILLO_HURT("entity.armadillo.hurt"),
|
||||||
|
ENTITY_ARMADILLO_AMBIENT("entity.armadillo.ambient"),
|
||||||
|
ENTITY_ARMADILLO_STEP("entity.armadillo.step"),
|
||||||
|
ENTITY_ARMADILLO_DEATH("entity.armadillo.death"),
|
||||||
|
ENTITY_ARMADILLO_ROLL("entity.armadillo.roll"),
|
||||||
|
ENTITY_ARMADILLO_LAND("entity.armadillo.land"),
|
||||||
|
ENTITY_ARMADILLO_SCUTE_DROP("entity.armadillo.scute_drop"),
|
||||||
|
ENTITY_ARMADILLO_UNROLL("entity.armadillo.unroll"),
|
||||||
|
ENTITY_ARMADILLO_BRUSH("entity.armadillo.brush"),
|
||||||
ITEM_ARMOR_EQUIP_CHAIN("item.armor.equip_chain"),
|
ITEM_ARMOR_EQUIP_CHAIN("item.armor.equip_chain"),
|
||||||
ITEM_ARMOR_EQUIP_DIAMOND("item.armor.equip_diamond"),
|
ITEM_ARMOR_EQUIP_DIAMOND("item.armor.equip_diamond"),
|
||||||
ITEM_ARMOR_EQUIP_ELYTRA("item.armor.equip_elytra"),
|
ITEM_ARMOR_EQUIP_ELYTRA("item.armor.equip_elytra"),
|
||||||
|
@ -70,6 +80,8 @@ public enum BuiltinSound implements Sound {
|
||||||
ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"),
|
ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"),
|
||||||
ITEM_ARMOR_EQUIP_NETHERITE("item.armor.equip_netherite"),
|
ITEM_ARMOR_EQUIP_NETHERITE("item.armor.equip_netherite"),
|
||||||
ITEM_ARMOR_EQUIP_TURTLE("item.armor.equip_turtle"),
|
ITEM_ARMOR_EQUIP_TURTLE("item.armor.equip_turtle"),
|
||||||
|
ITEM_ARMOR_EQUIP_WOLF("item.armor.equip_wolf"),
|
||||||
|
ITEM_ARMOR_UNEQUIP_WOLF("item.armor.unequip_wolf"),
|
||||||
ENTITY_ARMOR_STAND_BREAK("entity.armor_stand.break"),
|
ENTITY_ARMOR_STAND_BREAK("entity.armor_stand.break"),
|
||||||
ENTITY_ARMOR_STAND_FALL("entity.armor_stand.fall"),
|
ENTITY_ARMOR_STAND_FALL("entity.armor_stand.fall"),
|
||||||
ENTITY_ARMOR_STAND_HIT("entity.armor_stand.hit"),
|
ENTITY_ARMOR_STAND_HIT("entity.armor_stand.hit"),
|
||||||
|
@ -173,6 +185,8 @@ public enum BuiltinSound implements Sound {
|
||||||
ITEM_BOTTLE_EMPTY("item.bottle.empty"),
|
ITEM_BOTTLE_EMPTY("item.bottle.empty"),
|
||||||
ITEM_BOTTLE_FILL("item.bottle.fill"),
|
ITEM_BOTTLE_FILL("item.bottle.fill"),
|
||||||
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
|
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
|
||||||
|
ENTITY_BREEZE_CHARGE("entity.breeze.charge"),
|
||||||
|
ENTITY_BREEZE_DEFLECT("entity.breeze.deflect"),
|
||||||
ENTITY_BREEZE_INHALE("entity.breeze.inhale"),
|
ENTITY_BREEZE_INHALE("entity.breeze.inhale"),
|
||||||
ENTITY_BREEZE_IDLE_GROUND("entity.breeze.idle_ground"),
|
ENTITY_BREEZE_IDLE_GROUND("entity.breeze.idle_ground"),
|
||||||
ENTITY_BREEZE_IDLE_AIR("entity.breeze.idle_air"),
|
ENTITY_BREEZE_IDLE_AIR("entity.breeze.idle_air"),
|
||||||
|
@ -182,6 +196,7 @@ public enum BuiltinSound implements Sound {
|
||||||
ENTITY_BREEZE_SLIDE("entity.breeze.slide"),
|
ENTITY_BREEZE_SLIDE("entity.breeze.slide"),
|
||||||
ENTITY_BREEZE_DEATH("entity.breeze.death"),
|
ENTITY_BREEZE_DEATH("entity.breeze.death"),
|
||||||
ENTITY_BREEZE_HURT("entity.breeze.hurt"),
|
ENTITY_BREEZE_HURT("entity.breeze.hurt"),
|
||||||
|
ENTITY_BREEZE_WHIRL("entity.breeze.whirl"),
|
||||||
BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"),
|
BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"),
|
||||||
ITEM_BRUSH_BRUSHING_GENERIC("item.brush.brushing.generic"),
|
ITEM_BRUSH_BRUSHING_GENERIC("item.brush.brushing.generic"),
|
||||||
ITEM_BRUSH_BRUSHING_SAND("item.brush.brushing.sand"),
|
ITEM_BRUSH_BRUSHING_SAND("item.brush.brushing.sand"),
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket {
|
||||||
this.attributes = new ArrayList<>();
|
this.attributes = new ArrayList<>();
|
||||||
int length = helper.readVarInt(in);
|
int length = helper.readVarInt(in);
|
||||||
for (int index = 0; index < length; index++) {
|
for (int index = 0; index < length; index++) {
|
||||||
String key = helper.readString(in);
|
int attributeId = helper.readVarInt(in);
|
||||||
double value = in.readDouble();
|
double value = in.readDouble();
|
||||||
List<AttributeModifier> modifiers = new ArrayList<>();
|
List<AttributeModifier> modifiers = new ArrayList<>();
|
||||||
int len = helper.readVarInt(in);
|
int len = helper.readVarInt(in);
|
||||||
|
@ -36,7 +36,7 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket {
|
||||||
modifiers.add(new AttributeModifier(helper.readUUID(in), in.readDouble(), helper.readModifierOperation(in)));
|
modifiers.add(new AttributeModifier(helper.readUUID(in), in.readDouble(), helper.readModifierOperation(in)));
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeType type = AttributeType.Builtin.BUILTIN.computeIfAbsent(Identifier.formalize(key), AttributeType.Custom::new);
|
AttributeType type = AttributeType.Builtin.BUILTIN.get(attributeId); //.computeIfAbsent(attributeId, AttributeType.Custom::new); TODO
|
||||||
this.attributes.add(new Attribute(type, value, modifiers));
|
this.attributes.add(new Attribute(type, value, modifiers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket {
|
||||||
helper.writeVarInt(out, this.entityId);
|
helper.writeVarInt(out, this.entityId);
|
||||||
helper.writeVarInt(out, this.attributes.size());
|
helper.writeVarInt(out, this.attributes.size());
|
||||||
for (Attribute attribute : this.attributes) {
|
for (Attribute attribute : this.attributes) {
|
||||||
helper.writeString(out, attribute.getType().getIdentifier());
|
helper.writeVarInt(out, attribute.getType().getId());
|
||||||
out.writeDouble(attribute.getValue());
|
out.writeDouble(attribute.getValue());
|
||||||
helper.writeVarInt(out, attribute.getModifiers().size());
|
helper.writeVarInt(out, attribute.getModifiers().size());
|
||||||
for (AttributeModifier modifier : attribute.getModifiers()) {
|
for (AttributeModifier modifier : attribute.getModifiers()) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class ClientboundUpdateMobEffectPacket implements MinecraftPacket {
|
||||||
private static final int FLAG_AMBIENT = 0x01;
|
private static final int FLAG_AMBIENT = 0x01;
|
||||||
private static final int FLAG_SHOW_PARTICLES = 0x02;
|
private static final int FLAG_SHOW_PARTICLES = 0x02;
|
||||||
private static final int FLAG_SHOW_ICON = 0x04;
|
private static final int FLAG_SHOW_ICON = 0x04;
|
||||||
|
private static final int FLAG_BLEND = 0x08;
|
||||||
|
|
||||||
private final int entityId;
|
private final int entityId;
|
||||||
private final @NonNull Effect effect;
|
private final @NonNull Effect effect;
|
||||||
|
@ -28,7 +29,7 @@ public class ClientboundUpdateMobEffectPacket implements MinecraftPacket {
|
||||||
private final boolean ambient;
|
private final boolean ambient;
|
||||||
private final boolean showParticles;
|
private final boolean showParticles;
|
||||||
private final boolean showIcon;
|
private final boolean showIcon;
|
||||||
private final @Nullable CompoundTag factorData;
|
private final boolean blend;
|
||||||
|
|
||||||
public ClientboundUpdateMobEffectPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundUpdateMobEffectPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
||||||
this.entityId = helper.readVarInt(in);
|
this.entityId = helper.readVarInt(in);
|
||||||
|
@ -40,7 +41,7 @@ public class ClientboundUpdateMobEffectPacket implements MinecraftPacket {
|
||||||
this.ambient = (flags & FLAG_AMBIENT) != 0;
|
this.ambient = (flags & FLAG_AMBIENT) != 0;
|
||||||
this.showParticles = (flags & FLAG_SHOW_PARTICLES) != 0;
|
this.showParticles = (flags & FLAG_SHOW_PARTICLES) != 0;
|
||||||
this.showIcon = (flags & FLAG_SHOW_ICON) != 0;
|
this.showIcon = (flags & FLAG_SHOW_ICON) != 0;
|
||||||
this.factorData = helper.readNullable(in, helper::readAnyTagOrThrow);
|
this.blend = (flags & FLAG_BLEND) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,8 +61,10 @@ public class ClientboundUpdateMobEffectPacket implements MinecraftPacket {
|
||||||
if (this.showIcon) {
|
if (this.showIcon) {
|
||||||
flags |= FLAG_SHOW_ICON;
|
flags |= FLAG_SHOW_ICON;
|
||||||
}
|
}
|
||||||
|
if (this.blend) {
|
||||||
|
flags |= FLAG_BLEND;
|
||||||
|
}
|
||||||
|
|
||||||
out.writeByte(flags);
|
out.writeByte(flags);
|
||||||
helper.writeNullable(out, this.factorData, helper::writeAnyTag);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue