diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java index 2d0508bf..a10f0dc6 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java @@ -210,9 +210,9 @@ import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.Serverbound public class MinecraftCodec { public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion((1 << 30) | 208) + .protocolVersion((1 << 30) | 209) .helper(MinecraftCodecHelper::new) - .minecraftVersion("24w36a") + .minecraftVersion("24w37a") .state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder() .registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new) ) diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/DataComponentType.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/DataComponentType.java index b5053cb8..04682bf0 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/DataComponentType.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/DataComponentType.java @@ -46,13 +46,14 @@ public class DataComponentType { public static final DataComponentType CONSUMABLE = new DataComponentType<>(ItemCodecHelper::readConsumable, ItemCodecHelper::writeConsumable, ObjectDataComponent::new); public static final DataComponentType USE_REMAINDER = new DataComponentType<>(ItemCodecHelper::readItemStack, ItemCodecHelper::writeItemStack, ObjectDataComponent::new); public static final DataComponentType USE_COOLDOWN = new DataComponentType<>(ItemCodecHelper::readUseCooldown, ItemCodecHelper::writeUseCooldown, ObjectDataComponent::new); - public static final DataComponentType FIRE_RESISTANT = new DataComponentType<>(unitReader(), unitWriter(), ObjectDataComponent::new); + public static final DataComponentType DAMAGE_RESISTANT = new DataComponentType<>(ItemCodecHelper::readResourceLocation, ItemCodecHelper::writeResourceLocation, ObjectDataComponent::new); public static final DataComponentType TOOL = new DataComponentType<>(ItemCodecHelper::readToolData, ItemCodecHelper::writeToolData, ObjectDataComponent::new); public static final IntComponentType ENCHANTABLE = new IntComponentType(ItemCodecHelper::readVarInt, ItemCodecHelper::writeVarInt, IntDataComponent::new); public static final DataComponentType EQUIPPABLE = new DataComponentType<>(ItemCodecHelper::readEquippable, ItemCodecHelper::writeEquippable, ObjectDataComponent::new); public static final DataComponentType REPAIRABLE = new DataComponentType<>(ItemCodecHelper::readHolderSet, ItemCodecHelper::writeHolderSet, ObjectDataComponent::new); public static final DataComponentType GLIDER = new DataComponentType<>(unitReader(), unitWriter(), ObjectDataComponent::new); public static final DataComponentType TOOLTIP_STYLE = new DataComponentType<>(ItemCodecHelper::readResourceLocation, ItemCodecHelper::writeResourceLocation, ObjectDataComponent::new); + public static final DataComponentType> DEATH_PROTECTION = new DataComponentType<>(listReader(ItemCodecHelper::readConsumeEffect), listWriter(ItemCodecHelper::writeConsumeEffect), ObjectDataComponent::new); public static final DataComponentType STORED_ENCHANTMENTS = new DataComponentType<>(ItemCodecHelper::readItemEnchantments, ItemCodecHelper::writeItemEnchantments, ObjectDataComponent::new); public static final DataComponentType DYED_COLOR = new DataComponentType<>(ItemCodecHelper::readDyedItemColor, ItemCodecHelper::writeDyedItemColor, ObjectDataComponent::new); public static final IntComponentType MAP_COLOR = new IntComponentType((helper, input) -> input.readInt(), (helper, output, value) -> output.writeInt(value), IntDataComponent::new); diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java index e847c910..6dbdacfc 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java @@ -5,5 +5,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot; import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound; -public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable HolderSet allowedEntities, boolean dispensable) { +public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable HolderSet allowedEntities, + boolean dispensable, boolean swappable, boolean damageOnHurt) { } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java index cd83a290..fdc57b6b 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java @@ -172,7 +172,9 @@ public class ItemCodecHelper extends MinecraftCodecHelper { Key model = this.readNullable(buf, this::readResourceLocation); HolderSet allowedEntities = this.readNullable(buf, this::readHolderSet); boolean dispensable = buf.readBoolean(); - return new Equippable(slot, equipSound, model, allowedEntities, dispensable); + boolean swappable = buf.readBoolean(); + boolean damageOnHurt = buf.readBoolean(); + return new Equippable(slot, equipSound, model, allowedEntities, dispensable, swappable, damageOnHurt); } public void writeEquippable(ByteBuf buf, Equippable equippable) { @@ -187,6 +189,8 @@ public class ItemCodecHelper extends MinecraftCodecHelper { this.writeNullable(buf, equippable.model(), this::writeResourceLocation); this.writeNullable(buf, equippable.allowedEntities(), this::writeHolderSet); buf.writeBoolean(equippable.dispensable()); + buf.writeBoolean(equippable.swappable()); + buf.writeBoolean(equippable.damageOnHurt()); } public ItemAttributeModifiers readItemAttributeModifiers(ByteBuf buf) { @@ -231,7 +235,8 @@ public class ItemCodecHelper extends MinecraftCodecHelper { int customColor = buf.readBoolean() ? buf.readInt() : -1; List customEffects = this.readList(buf, this::readEffectInstance); - return new PotionContents(potionId, customColor, customEffects); + String customName = this.readNullable(buf, this::readString); + return new PotionContents(potionId, customColor, customEffects, customName); } public void writePotionContents(ByteBuf buf, PotionContents contents) { @@ -250,6 +255,7 @@ public class ItemCodecHelper extends MinecraftCodecHelper { } this.writeList(buf, contents.getCustomEffects(), this::writeEffectInstance); + this.writeNullable(buf, contents.getCustomName(), this::writeString); } public FoodProperties readFoodProperties(ByteBuf buf) { diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/PotionContents.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/PotionContents.java index dd7fbe4e..cdc33531 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/PotionContents.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/PotionContents.java @@ -2,6 +2,7 @@ package org.geysermc.mcprotocollib.protocol.data.game.item.component; import lombok.AllArgsConstructor; import lombok.Data; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.List; @@ -11,4 +12,5 @@ public class PotionContents { private final int potionId; private final int customColor; private final List customEffects; + private final @Nullable String customName; } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java index ad686a9d..b92b513c 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java @@ -33,8 +33,8 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket { this.id = helper.readVarInt(in); this.position = Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble()); this.deltaMovement = Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble()); - this.yRot = in.readByte() * 360 / 256F; - this.xRot = in.readByte() * 360 / 256F; + this.yRot = in.readFloat(); + this.xRot = in.readFloat(); this.relativeArguments = new ArrayList<>(); int flags = in.readInt(); @@ -56,11 +56,8 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket { out.writeDouble(this.deltaMovement.getX()); out.writeDouble(this.deltaMovement.getY()); out.writeDouble(this.deltaMovement.getZ()); - - float yRot = this.yRot * 256F / 360F; - out.writeByte(yRot < (int)yRot ? (int)yRot - 1 : (int)yRot); - float xRot = this.xRot * 256F / 360F; - out.writeByte(xRot < (int)xRot ? (int)xRot - 1 : (int)xRot); + out.writeFloat(this.yRot); + out.writeFloat(this.xRot); int flags = 0; for (PositionElement element : this.relativeArguments) {