diff --git a/protocol/build.gradle.kts b/protocol/build.gradle.kts index 41f64b93..6de81ae6 100644 --- a/protocol/build.gradle.kts +++ b/protocol/build.gradle.kts @@ -3,7 +3,7 @@ plugins { jacoco } -version = "1.21.2-SNAPSHOT" +version = "1.21.4-SNAPSHOT" description = "MCProtocolLib is a simple library for communicating with Minecraft clients and servers." dependencies { 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 63b782f5..57e1650a 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 @@ -162,7 +162,8 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.S import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerSlotStateChangedPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundEditBookPacket; -import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemFromBlockPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemFromEntityPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPlaceRecipePacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundRecipeBookChangeSettingsPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundRecipeBookSeenRecipePacket; @@ -214,9 +215,9 @@ import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.Serverbound public class MinecraftCodec { public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion(768) + .protocolVersion((1 << 30) | 220) .helper(MinecraftCodecHelper::new) - .minecraftVersion("1.21.3") + .minecraftVersion("24w44a") .state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder() .registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new) ) @@ -429,7 +430,8 @@ public class MinecraftCodec { .registerServerboundPacket(ServerboundMovePlayerStatusOnlyPacket.class, ServerboundMovePlayerStatusOnlyPacket::new) .registerServerboundPacket(ServerboundMoveVehiclePacket.class, ServerboundMoveVehiclePacket::new) .registerServerboundPacket(ServerboundPaddleBoatPacket.class, ServerboundPaddleBoatPacket::new) - .registerServerboundPacket(ServerboundPickItemPacket.class, ServerboundPickItemPacket::new) + .registerServerboundPacket(ServerboundPickItemFromBlockPacket.class, ServerboundPickItemFromBlockPacket::new) + .registerServerboundPacket(ServerboundPickItemFromEntityPacket.class, ServerboundPickItemFromEntityPacket::new) .registerServerboundPacket(ServerboundPingRequestPacket.class, ServerboundPingRequestPacket::new) .registerServerboundPacket(ServerboundPlaceRecipePacket.class, ServerboundPlaceRecipePacket::new) .registerServerboundPacket(ServerboundPlayerAbilitiesPacket.class, ServerboundPlayerAbilitiesPacket::new) diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java index cd42072b..85394b0b 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java @@ -73,7 +73,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.particle.ParticleData import org.geysermc.mcprotocollib.protocol.data.game.level.particle.ParticleType; import org.geysermc.mcprotocollib.protocol.data.game.level.particle.SculkChargeParticleData; import org.geysermc.mcprotocollib.protocol.data.game.level.particle.ShriekParticleData; -import org.geysermc.mcprotocollib.protocol.data.game.level.particle.TargetColorParticleData; +import org.geysermc.mcprotocollib.protocol.data.game.level.particle.TraiParticleData; import org.geysermc.mcprotocollib.protocol.data.game.level.particle.VibrationParticleData; import org.geysermc.mcprotocollib.protocol.data.game.level.particle.positionsource.BlockPositionSource; import org.geysermc.mcprotocollib.protocol.data.game.level.particle.positionsource.EntityPositionSource; @@ -725,7 +725,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { case ITEM -> new ItemParticleData(this.readOptionalItemStack(buf)); case SCULK_CHARGE -> new SculkChargeParticleData(buf.readFloat()); case SHRIEK -> new ShriekParticleData(this.readVarInt(buf)); - case TRAIL -> new TargetColorParticleData(Vector3d.from(buf.readDouble(), buf.readDouble(), buf.readDouble()), buf.readInt()); + case TRAIL -> new TraiParticleData(Vector3d.from(buf.readDouble(), buf.readDouble(), buf.readDouble()), buf.readInt(), this.readVarInt(buf)); case VIBRATION -> new VibrationParticleData(this.readPositionSource(buf), this.readVarInt(buf)); default -> null; }; @@ -765,11 +765,12 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { this.writeVarInt(buf, shriekData.getDelay()); } case TRAIL -> { - TargetColorParticleData targetColorData = (TargetColorParticleData) data; - buf.writeDouble(targetColorData.target().getX()); - buf.writeDouble(targetColorData.target().getY()); - buf.writeDouble(targetColorData.target().getZ()); - buf.writeInt(targetColorData.color()); + TraiParticleData trailData = (TraiParticleData) data; + buf.writeDouble(trailData.target().getX()); + buf.writeDouble(trailData.target().getY()); + buf.writeDouble(trailData.target().getZ()); + buf.writeInt(trailData.color()); + this.writeVarInt(buf, trailData.duration()); } case VIBRATION -> { VibrationParticleData vibrationData = (VibrationParticleData) data; diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntry.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntry.java index 72644a08..633c20c6 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntry.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntry.java @@ -20,6 +20,7 @@ public class PlayerListEntry { private int latency; private GameMode gameMode; private @Nullable Component displayName; + private boolean showHat; private int listOrder; private UUID sessionId; private long expiresAt; @@ -27,6 +28,6 @@ public class PlayerListEntry { private byte @Nullable [] keySignature; public PlayerListEntry(UUID profileId) { - this(profileId, null, false, 0, GameMode.SURVIVAL, null, 0, null, 0, null, null); + this(profileId, null, false, 0, GameMode.SURVIVAL, null, false, 0, null, 0, null, null); } } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntryAction.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntryAction.java index 9b435b34..100e10fd 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntryAction.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/PlayerListEntryAction.java @@ -7,6 +7,7 @@ public enum PlayerListEntryAction { UPDATE_LISTED, UPDATE_LATENCY, UPDATE_DISPLAY_NAME, + UPDATE_HAT, UPDATE_LIST_ORDER; public static final PlayerListEntryAction[] VALUES = values(); diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/ParticleType.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/ParticleType.java index 02e5c673..5805571c 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/ParticleType.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/ParticleType.java @@ -35,6 +35,7 @@ public enum ParticleType { FLAME, INFESTED, CHERRY_LEAVES, + PALE_OAK_LEAVES, SCULK_SOUL, SCULK_CHARGE, SCULK_CHARGE_POP, diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/TargetColorParticleData.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/TraiParticleData.java similarity index 54% rename from protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/TargetColorParticleData.java rename to protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/TraiParticleData.java index bf46074e..04748569 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/TargetColorParticleData.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/TraiParticleData.java @@ -2,5 +2,5 @@ package org.geysermc.mcprotocollib.protocol.data.game.level.particle; import org.cloudburstmc.math.vector.Vector3d; -public record TargetColorParticleData(Vector3d target, int color) implements ParticleData { +public record TraiParticleData(Vector3d target, int color, int duration) implements ParticleData { } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java index 3f17016e..ef58607b 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java @@ -391,6 +391,7 @@ public enum BuiltinSound implements Sound { ENTITY_CREAKING_UNFREEZE("entity.creaking.unfreeze"), ENTITY_CREAKING_SPAWN("entity.creaking.spawn"), ENTITY_CREAKING_SWAY("entity.creaking.sway"), + ENTITY_CREAKING_TWITCH("entity.creaking.twitch"), BLOCK_CREAKING_HEART_BREAK("block.creaking_heart.break"), BLOCK_CREAKING_HEART_FALL("block.creaking_heart.fall"), BLOCK_CREAKING_HEART_HIT("block.creaking_heart.hit"), @@ -529,6 +530,11 @@ public enum BuiltinSound implements Sound { ENTITY_EVOKER_PREPARE_WOLOLO("entity.evoker.prepare_wololo"), ENTITY_EXPERIENCE_BOTTLE_THROW("entity.experience_bottle.throw"), ENTITY_EXPERIENCE_ORB_PICKUP("entity.experience_orb.pickup"), + BLOCK_EYEBLOSSOM_OPEN_LONG("block.eyeblossom.open_long"), + BLOCK_EYEBLOSSOM_OPEN("block.eyeblossom.open"), + BLOCK_EYEBLOSSOM_CLOSE_LONG("block.eyeblossom.close_long"), + BLOCK_EYEBLOSSOM_CLOSE("block.eyeblossom.close"), + BLOCK_EYEBLOSSOM_IDLE("block.eyeblossom.idle"), BLOCK_FENCE_GATE_CLOSE("block.fence_gate.close"), BLOCK_FENCE_GATE_OPEN("block.fence_gate.open"), ITEM_FIRECHARGE_USE("item.firecharge.use"), @@ -1329,6 +1335,16 @@ public enum BuiltinSound implements Sound { BLOCK_SPAWNER_HIT("block.spawner.hit"), BLOCK_SPAWNER_PLACE("block.spawner.place"), BLOCK_SPAWNER_STEP("block.spawner.step"), + BLOCK_RESIN_BREAK("block.resin.break"), + BLOCK_RESIN_FALL("block.resin.fall"), + BLOCK_RESIN_HIT("block.resin.hit"), + BLOCK_RESIN_PLACE("block.resin.place"), + BLOCK_RESIN_STEP("block.resin.step"), + BLOCK_RESIN_BRICKS_BREAK("block.resin_bricks.break"), + BLOCK_RESIN_BRICKS_FALL("block.resin_bricks.fall"), + BLOCK_RESIN_BRICKS_HIT("block.resin_bricks.hit"), + BLOCK_RESIN_BRICKS_PLACE("block.resin_bricks.place"), + BLOCK_RESIN_BRICKS_STEP("block.resin_bricks.step"), BLOCK_SPORE_BLOSSOM_BREAK("block.spore_blossom.break"), BLOCK_SPORE_BLOSSOM_FALL("block.spore_blossom.fall"), BLOCK_SPORE_BLOSSOM_HIT("block.spore_blossom.hit"), diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java index 323c6399..bf24e958 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java @@ -80,6 +80,11 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket { entry.setListOrder(listOrder); } + case UPDATE_HAT -> { + boolean showHat = in.readBoolean(); + + entry.setShowHat(showHat); + } } } @@ -117,6 +122,7 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket { case UPDATE_LATENCY -> helper.writeVarInt(out, entry.getLatency()); case UPDATE_DISPLAY_NAME -> helper.writeNullable(out, entry.getDisplayName(), helper::writeComponent); case UPDATE_LIST_ORDER -> helper.writeVarInt(out, entry.getListOrder()); + case UPDATE_HAT -> out.writeBoolean(entry.isShowHat()); } } } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHeldSlotPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHeldSlotPacket.java index ef15bf9c..e8104557 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHeldSlotPacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHeldSlotPacket.java @@ -14,11 +14,11 @@ public class ClientboundSetHeldSlotPacket implements MinecraftPacket { private final int slot; public ClientboundSetHeldSlotPacket(ByteBuf in, MinecraftCodecHelper helper) { - this.slot = in.readByte(); + this.slot = helper.readVarInt(in); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) { - out.writeByte(this.slot); + helper.writeVarInt(out, this.slot); } } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundBlockEventPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundBlockEventPacket.java index fb9651a7..e88f77f9 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundBlockEventPacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundBlockEventPacket.java @@ -39,13 +39,13 @@ public class ClientboundBlockEventPacket implements MinecraftPacket { private static final int PISTON = 135; private static final int MOB_SPAWNER = 182; private static final int CHEST = 185; - private static final int ENDER_CHEST = 358; - private static final int TRAPPED_CHEST = 427; - private static final int END_GATEWAY = 624; - private static final int SHULKER_BOX_LOWER = 634; - private static final int SHULKER_BOX_HIGHER = 650; - private static final int BELL = 804; - private static final int DECORATED_POT = 1076; + private static final int ENDER_CHEST = 365; + private static final int TRAPPED_CHEST = 434; + private static final int END_GATEWAY = 631; + private static final int SHULKER_BOX_LOWER = 641; + private static final int SHULKER_BOX_HIGHER = 657; + private static final int BELL = 811; + private static final int DECORATED_POT = 1083; private final @NonNull Vector3i position; private final @NonNull BlockValueType type; diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java index 0f9de3cb..7aa273de 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java @@ -16,6 +16,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.particle.ParticleType public class ClientboundLevelParticlesPacket implements MinecraftPacket { private final @NonNull Particle particle; private final boolean longDistance; + private final boolean alwaysShow; private final double x; private final double y; private final double z; @@ -27,6 +28,7 @@ public class ClientboundLevelParticlesPacket implements MinecraftPacket { public ClientboundLevelParticlesPacket(ByteBuf in, MinecraftCodecHelper helper) { this.longDistance = in.readBoolean(); + this.alwaysShow = in.readBoolean(); this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); @@ -42,6 +44,7 @@ public class ClientboundLevelParticlesPacket implements MinecraftPacket { @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeBoolean(this.longDistance); + out.writeBoolean(this.alwaysShow); out.writeDouble(this.x); out.writeDouble(this.y); out.writeDouble(this.z); diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemFromBlockPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemFromBlockPacket.java new file mode 100644 index 00000000..1d89c256 --- /dev/null +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemFromBlockPacket.java @@ -0,0 +1,28 @@ +package org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory; + +import io.netty.buffer.ByteBuf; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; +import org.cloudburstmc.math.vector.Vector3i; +import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper; +import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; + +@Data +@With +@AllArgsConstructor +public class ServerboundPickItemFromBlockPacket implements MinecraftPacket { + private final Vector3i pos; + private final boolean includeData; + + public ServerboundPickItemFromBlockPacket(ByteBuf in, MinecraftCodecHelper helper) { + this.pos = helper.readPosition(in); + this.includeData = in.readBoolean(); + } + + @Override + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { + helper.writePosition(out, this.pos); + out.writeBoolean(this.includeData); + } +} diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemFromEntityPacket.java similarity index 53% rename from protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemPacket.java rename to protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemFromEntityPacket.java index dd6d1b31..3ff338bf 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemPacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemFromEntityPacket.java @@ -10,15 +10,18 @@ import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; @Data @With @AllArgsConstructor -public class ServerboundPickItemPacket implements MinecraftPacket { - private final int slot; +public class ServerboundPickItemFromEntityPacket implements MinecraftPacket { + private final int id; + private final boolean includeData; - public ServerboundPickItemPacket(ByteBuf in, MinecraftCodecHelper helper) { - this.slot = helper.readVarInt(in); + public ServerboundPickItemFromEntityPacket(ByteBuf in, MinecraftCodecHelper helper) { + this.id = helper.readVarInt(in); + this.includeData = in.readBoolean(); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) { - helper.writeVarInt(out, this.slot); + helper.writeVarInt(out, this.id); + out.writeBoolean(this.includeData); } } diff --git a/protocol/src/main/resources/networkCodec.nbt b/protocol/src/main/resources/networkCodec.nbt index 5c9b65c9..48372c3b 100644 Binary files a/protocol/src/main/resources/networkCodec.nbt and b/protocol/src/main/resources/networkCodec.nbt differ