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 57e1650a..a16a53c6 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 @@ -157,6 +157,7 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.Serverbound import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundConfigurationAcknowledgedPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundDebugSampleSubscriptionPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundLockDifficultyPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundPlayerLoadedPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerButtonClickPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClickPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket; @@ -215,9 +216,9 @@ import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.Serverbound public class MinecraftCodec { public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion((1 << 30) | 220) + .protocolVersion((1 << 30) | 221) .helper(MinecraftCodecHelper::new) - .minecraftVersion("24w44a") + .minecraftVersion("24w45a") .state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder() .registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new) ) @@ -438,6 +439,7 @@ public class MinecraftCodec { .registerServerboundPacket(ServerboundPlayerActionPacket.class, ServerboundPlayerActionPacket::new) .registerServerboundPacket(ServerboundPlayerCommandPacket.class, ServerboundPlayerCommandPacket::new) .registerServerboundPacket(ServerboundPlayerInputPacket.class, ServerboundPlayerInputPacket::new) + .registerServerboundPacket(ServerboundPlayerLoadedPacket.class, (buf, helper) -> ServerboundPlayerLoadedPacket.INSTANCE) .registerServerboundPacket(ServerboundPongPacket.class, ServerboundPongPacket::new) .registerServerboundPacket(ServerboundRecipeBookChangeSettingsPacket.class, ServerboundRecipeBookChangeSettingsPacket::new) .registerServerboundPacket(ServerboundRecipeBookSeenRecipePacket.class, ServerboundRecipeBookSeenRecipePacket::new) diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ArmorTrim.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ArmorTrim.java index f7e53664..103feaf2 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ArmorTrim.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ArmorTrim.java @@ -7,8 +7,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.Holder; import java.util.Map; public record ArmorTrim(Holder material, Holder pattern, boolean showInTooltip) { - public record TrimMaterial(String assetName, int ingredientId, float itemModelIndex, - Map overrideArmorMaterials, Component description) { + public record TrimMaterial(String assetName, int ingredientId, Map overrideArmorAssets, Component description) { } public record TrimPattern(Key assetId, int templateItemId, Component description, boolean decal) { diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/CustomModelData.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/CustomModelData.java new file mode 100644 index 00000000..e6cabb40 --- /dev/null +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/CustomModelData.java @@ -0,0 +1,6 @@ +package org.geysermc.mcprotocollib.protocol.data.game.item.component; + +import java.util.List; + +public record CustomModelData(List floats, List flags, List strings, List colors) { +} 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 889a2599..5e83a2fb 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 @@ -35,7 +35,7 @@ public class DataComponentType { public static final DataComponentType CAN_PLACE_ON = new DataComponentType<>(ItemCodecHelper::readAdventureModePredicate, ItemCodecHelper::writeAdventureModePredicate, ObjectDataComponent::new); public static final DataComponentType CAN_BREAK = new DataComponentType<>(ItemCodecHelper::readAdventureModePredicate, ItemCodecHelper::writeAdventureModePredicate, ObjectDataComponent::new); public static final DataComponentType ATTRIBUTE_MODIFIERS = new DataComponentType<>(ItemCodecHelper::readItemAttributeModifiers, ItemCodecHelper::writeItemAttributeModifiers, ObjectDataComponent::new); - public static final IntComponentType CUSTOM_MODEL_DATA = new IntComponentType(ItemCodecHelper::readVarInt, ItemCodecHelper::writeVarInt, IntDataComponent::new); + public static final DataComponentType CUSTOM_MODEL_DATA = new DataComponentType<>(ItemCodecHelper::readCustomModelData, ItemCodecHelper::writeCustomModelData, ObjectDataComponent::new); public static final DataComponentType HIDE_ADDITIONAL_TOOLTIP = new DataComponentType<>(unitReader(), unitWriter(), ObjectDataComponent::new); public static final DataComponentType HIDE_TOOLTIP = new DataComponentType<>(unitReader(), unitWriter(), ObjectDataComponent::new); public static final IntComponentType REPAIR_COST = new IntComponentType(ItemCodecHelper::readVarInt, ItemCodecHelper::writeVarInt, IntDataComponent::new); 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 85b3ef54..9b48bd96 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 @@ -193,6 +193,21 @@ public class ItemCodecHelper extends MinecraftCodecHelper { buf.writeBoolean(modifiers.isShowInTooltip()); } + public CustomModelData readCustomModelData(ByteBuf buf) { + List floats = this.readList(buf, ByteBuf::readFloat); + List flags = this.readList(buf, ByteBuf::readBoolean); + List strings = this.readList(buf, this::readString); + List colors = this.readList(buf, ByteBuf::readInt); + return new CustomModelData(floats, flags, strings, colors); + } + + public void writeCustomModelData(ByteBuf buf, CustomModelData modelData) { + this.writeList(buf, modelData.floats(), ByteBuf::writeFloat); + this.writeList(buf, modelData.flags(), ByteBuf::writeBoolean); + this.writeList(buf, modelData.strings(), this::writeString); + this.writeList(buf, modelData.colors(), ByteBuf::writeInt); + } + public DyedItemColor readDyedItemColor(ByteBuf buf) { return new DyedItemColor(buf.readInt(), buf.readBoolean()); } @@ -394,7 +409,6 @@ public class ItemCodecHelper extends MinecraftCodecHelper { public ArmorTrim.TrimMaterial readTrimMaterial(ByteBuf buf) { String assetName = this.readString(buf); int ingredientId = this.readVarInt(buf); - float itemModelIndex = buf.readFloat(); Map overrideArmorMaterials = new HashMap<>(); int overrideCount = this.readVarInt(buf); @@ -403,16 +417,15 @@ public class ItemCodecHelper extends MinecraftCodecHelper { } Component description = this.readComponent(buf); - return new ArmorTrim.TrimMaterial(assetName, ingredientId, itemModelIndex, overrideArmorMaterials, description); + return new ArmorTrim.TrimMaterial(assetName, ingredientId, overrideArmorMaterials, description); } public void writeTrimMaterial(ByteBuf buf, ArmorTrim.TrimMaterial material) { this.writeString(buf, material.assetName()); this.writeVarInt(buf, material.ingredientId()); - buf.writeFloat(material.itemModelIndex()); - this.writeVarInt(buf, material.overrideArmorMaterials().size()); - for (Map.Entry entry : material.overrideArmorMaterials().entrySet()) { + this.writeVarInt(buf, material.overrideArmorAssets().size()); + for (Map.Entry entry : material.overrideArmorAssets().entrySet()) { this.writeResourceLocation(buf, entry.getKey()); this.writeString(buf, entry.getValue()); } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java index 989860d0..385f2424 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; +import org.cloudburstmc.math.vector.Vector3d; import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper; import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; @@ -11,26 +12,22 @@ import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; @With @AllArgsConstructor public class ClientboundMoveVehiclePacket implements MinecraftPacket { - private final double x; - private final double y; - private final double z; - private final float yaw; - private final float pitch; + private final Vector3d position; + private final float yRot; + private final float xRot; public ClientboundMoveVehiclePacket(ByteBuf in, MinecraftCodecHelper helper) { - this.x = in.readDouble(); - this.y = in.readDouble(); - this.z = in.readDouble(); - this.yaw = in.readFloat(); - this.pitch = in.readFloat(); + this.position = Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble()); + this.yRot = in.readFloat(); + this.xRot = in.readFloat(); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) { - out.writeDouble(this.x); - out.writeDouble(this.y); - out.writeDouble(this.z); - out.writeFloat(this.yaw); - out.writeFloat(this.pitch); + out.writeDouble(this.position.getX()); + out.writeDouble(this.position.getY()); + out.writeDouble(this.position.getZ()); + out.writeFloat(this.yRot); + out.writeFloat(this.xRot); } } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/ServerboundPlayerLoadedPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/ServerboundPlayerLoadedPacket.java new file mode 100644 index 00000000..49f44411 --- /dev/null +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/ServerboundPlayerLoadedPacket.java @@ -0,0 +1,18 @@ +package org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper; +import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; + +@Data +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class ServerboundPlayerLoadedPacket implements MinecraftPacket { + public static final ServerboundPlayerLoadedPacket INSTANCE = new ServerboundPlayerLoadedPacket(); + + @Override + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { + } +} diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java index 7672d0b6..36816394 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; +import org.cloudburstmc.math.vector.Vector3d; import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper; import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; @@ -11,26 +12,25 @@ import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; @With @AllArgsConstructor public class ServerboundMoveVehiclePacket implements MinecraftPacket { - private final double x; - private final double y; - private final double z; - private final float yaw; - private final float pitch; + private final Vector3d position; + private final float yRot; + private final float xRot; + private final boolean onGround; public ServerboundMoveVehiclePacket(ByteBuf in, MinecraftCodecHelper helper) { - this.x = in.readDouble(); - this.y = in.readDouble(); - this.z = in.readDouble(); - this.yaw = in.readFloat(); - this.pitch = in.readFloat(); + this.position = Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble()); + this.yRot = in.readFloat(); + this.xRot = in.readFloat(); + this.onGround = in.readBoolean(); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) { - out.writeDouble(this.x); - out.writeDouble(this.y); - out.writeDouble(this.z); - out.writeFloat(this.yaw); - out.writeFloat(this.pitch); + out.writeDouble(this.position.getX()); + out.writeDouble(this.position.getY()); + out.writeDouble(this.position.getZ()); + out.writeFloat(this.yRot); + out.writeFloat(this.xRot); + out.writeBoolean(this.onGround); } } diff --git a/protocol/src/main/resources/networkCodec.nbt b/protocol/src/main/resources/networkCodec.nbt index 48372c3b..00853fc3 100644 Binary files a/protocol/src/main/resources/networkCodec.nbt and b/protocol/src/main/resources/networkCodec.nbt differ