Skip to content

Commit 1a11b93

Browse files
authored
Merge feature 1.21.6
2 parents 79f13d6 + 4130352 commit 1a11b93

36 files changed

Lines changed: 526 additions & 53 deletions

protocol/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
jacoco
44
}
55

6-
version = "1.21.5-SNAPSHOT"
6+
version = "1.21.6-SNAPSHOT"
77
description = "MCProtocolLib is a simple library for communicating with Minecraft clients and servers."
88

99
dependencies {

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.geysermc.mcprotocollib.protocol.codec;
22

33
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
4+
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundClearDialogPacket;
45
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket;
56
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCustomReportDetailsPacket;
67
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundDisconnectPacket;
@@ -13,6 +14,7 @@
1314
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundTransferPacket;
1415
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundUpdateTagsPacket;
1516
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundClientInformationPacket;
17+
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundCustomClickActionPacket;
1618
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
1719
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundKeepAlivePacket;
1820
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundPongPacket;
@@ -21,6 +23,7 @@
2123
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket;
2224
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundResetChatPacket;
2325
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundSelectKnownPacks;
26+
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundShowDialogConfigurationPacket;
2427
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundUpdateEnabledFeaturesPacket;
2528
import org.geysermc.mcprotocollib.protocol.packet.configuration.serverbound.ServerboundFinishConfigurationPacket;
2629
import org.geysermc.mcprotocollib.protocol.packet.configuration.serverbound.ServerboundSelectKnownPacks;
@@ -49,6 +52,7 @@
4952
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSelectAdvancementsTabPacket;
5053
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundServerDataPacket;
5154
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSetCameraPacket;
55+
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundShowDialogGamePacket;
5256
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSoundEntityPacket;
5357
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundStartConfigurationPacket;
5458
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundStopSoundPacket;
@@ -59,6 +63,7 @@
5963
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTickingStepPacket;
6064
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundUpdateAdvancementsPacket;
6165
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundUpdateRecipesPacket;
66+
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAddEntityPacket;
6267
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAnimatePacket;
6368
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundDamageEventPacket;
6469
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
@@ -93,7 +98,6 @@
9398
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetExperiencePacket;
9499
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
95100
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHeldSlotPacket;
96-
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAddEntityPacket;
97101
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerClosePacket;
98102
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetContentPacket;
99103
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetDataPacket;
@@ -129,6 +133,7 @@
129133
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundSetTimePacket;
130134
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundSoundPacket;
131135
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundTagQueryPacket;
136+
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundTrackedWaypointPacket;
132137
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.border.ClientboundInitializeBorderPacket;
133138
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.border.ClientboundSetBorderCenterPacket;
134139
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.border.ClientboundSetBorderLerpSizePacket;
@@ -190,6 +195,7 @@
190195
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundSignUpdatePacket;
191196
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundTeleportToEntityPacket;
192197
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundTestInstanceBlockActionPacket;
198+
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundChangeGameModePacket;
193199
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
194200
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
195201
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
@@ -218,8 +224,8 @@
218224

219225
public class MinecraftCodec {
220226
public static final PacketCodec CODEC = PacketCodec.builder()
221-
.protocolVersion(770)
222-
.minecraftVersion("1.21.5")
227+
.protocolVersion(771)
228+
.minecraftVersion("1.21.6")
223229
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
224230
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
225231
)
@@ -258,6 +264,8 @@ public class MinecraftCodec {
258264
.registerClientboundPacket(ClientboundSelectKnownPacks.class, ClientboundSelectKnownPacks::new)
259265
.registerClientboundPacket(ClientboundCustomReportDetailsPacket.class, ClientboundCustomReportDetailsPacket::new)
260266
.registerClientboundPacket(ClientboundServerLinksPacket.class, ClientboundServerLinksPacket::new)
267+
.registerClientboundPacket(ClientboundClearDialogPacket.class, ClientboundClearDialogPacket::new)
268+
.registerClientboundPacket(ClientboundShowDialogConfigurationPacket.class, ClientboundShowDialogConfigurationPacket::new)
261269
.registerServerboundPacket(ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new)
262270
.registerServerboundPacket(ServerboundCookieResponsePacket.class, ServerboundCookieResponsePacket::new)
263271
.registerServerboundPacket(ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new)
@@ -266,6 +274,7 @@ public class MinecraftCodec {
266274
.registerServerboundPacket(ServerboundPongPacket.class, ServerboundPongPacket::new)
267275
.registerServerboundPacket(ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new)
268276
.registerServerboundPacket(ServerboundSelectKnownPacks.class, ServerboundSelectKnownPacks::new)
277+
.registerServerboundPacket(ServerboundCustomClickActionPacket.class, ServerboundCustomClickActionPacket::new)
269278
).state(ProtocolState.GAME, MinecraftPacketRegistry.builder()
270279
.registerClientboundPacket(ClientboundDelimiterPacket.class, ClientboundDelimiterPacket::new)
271280
.registerClientboundPacket(ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new)
@@ -398,10 +407,14 @@ public class MinecraftCodec {
398407
.registerClientboundPacket(ClientboundProjectilePowerPacket.class, ClientboundProjectilePowerPacket::new)
399408
.registerClientboundPacket(ClientboundCustomReportDetailsPacket.class, ClientboundCustomReportDetailsPacket::new)
400409
.registerClientboundPacket(ClientboundServerLinksPacket.class, ClientboundServerLinksPacket::new)
410+
.registerClientboundPacket(ClientboundTrackedWaypointPacket.class, ClientboundTrackedWaypointPacket::new)
411+
.registerClientboundPacket(ClientboundClearDialogPacket.class, ClientboundClearDialogPacket::new)
412+
.registerClientboundPacket(ClientboundShowDialogGamePacket.class, ClientboundShowDialogGamePacket::new)
401413
.registerServerboundPacket(ServerboundAcceptTeleportationPacket.class, ServerboundAcceptTeleportationPacket::new)
402414
.registerServerboundPacket(ServerboundBlockEntityTagQueryPacket.class, ServerboundBlockEntityTagQueryPacket::new)
403415
.registerServerboundPacket(ServerboundSelectBundleItemPacket.class, ServerboundSelectBundleItemPacket::new)
404416
.registerServerboundPacket(ServerboundChangeDifficultyPacket.class, ServerboundChangeDifficultyPacket::new)
417+
.registerServerboundPacket(ServerboundChangeGameModePacket.class, ServerboundChangeGameModePacket::new)
405418
.registerServerboundPacket(ServerboundChatAckPacket.class, ServerboundChatAckPacket::new)
406419
.registerServerboundPacket(ServerboundChatCommandPacket.class, ServerboundChatCommandPacket::new)
407420
.registerServerboundPacket(ServerboundChatCommandSignedPacket.class, ServerboundChatCommandSignedPacket::new)
@@ -462,6 +475,7 @@ public class MinecraftCodec {
462475
.registerServerboundPacket(ServerboundTestInstanceBlockActionPacket.class, ServerboundTestInstanceBlockActionPacket::new)
463476
.registerServerboundPacket(ServerboundUseItemOnPacket.class, ServerboundUseItemOnPacket::new)
464477
.registerServerboundPacket(ServerboundUseItemPacket.class, ServerboundUseItemPacket::new)
478+
.registerServerboundPacket(ServerboundCustomClickActionPacket.class, ServerboundCustomClickActionPacket::new)
465479
)
466480
.build();
467481
}

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftTypes.java

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,32 @@ public static <T> void writeList(ByteBuf buf, List<T> value, BiConsumer<ByteBuf,
244244
}
245245
}
246246

247+
public static <T> T readLengthPrefixed(ByteBuf buf, int maxLength, Function<ByteBuf, T> reader) {
248+
int length = MinecraftTypes.readVarInt(buf);
249+
if (length > maxLength) {
250+
throw new IllegalArgumentException("Buffer is longer than maximum allowed length");
251+
} else {
252+
return reader.apply(buf);
253+
}
254+
}
255+
256+
public static <T> void writeLengthPrefixed(ByteBuf buf, int maxLength, T value, BiConsumer<ByteBuf, T> writer) {
257+
ByteBuf buf2 = Unpooled.buffer();
258+
259+
try {
260+
writer.accept(buf2, value);
261+
int length = buf2.readableBytes();
262+
if (length > maxLength) {
263+
throw new IllegalArgumentException("Buffer is longer than maximum allowed length");
264+
}
265+
266+
MinecraftTypes.writeVarInt(buf, length);
267+
buf.writeBytes(buf2);
268+
} finally {
269+
buf2.release();
270+
}
271+
}
272+
247273
public static <T> Holder<T> readHolder(ByteBuf buf, Function<ByteBuf, T> readCustom) {
248274
int registryId = MinecraftTypes.readVarInt(buf);
249275
return registryId == 0 ? Holder.ofCustom(readCustom.apply(buf)) : Holder.ofId(registryId - 1);
@@ -482,8 +508,7 @@ public static DataComponents readDataComponentPatch(ByteBuf buf, boolean untrust
482508
if (untrusted) {
483509
for (int k = 0; k < nonNullComponents; k++) {
484510
DataComponentType<?> dataComponentType = DataComponentTypes.read(buf);
485-
MinecraftTypes.readVarInt(buf);
486-
DataComponent<?, ?> dataComponent = dataComponentType.readDataComponent(buf);
511+
DataComponent<?, ?> dataComponent = MinecraftTypes.readLengthPrefixed(buf, Integer.MAX_VALUE, dataComponentType::readDataComponent);
487512
dataComponents.put(dataComponentType, dataComponent);
488513
}
489514
} else {
@@ -525,11 +550,7 @@ public static void writeDataComponentPatch(ByteBuf buf, DataComponents dataCompo
525550
for (DataComponent<?, ?> component : dataComponents.getDataComponents().values()) {
526551
if (component.getValue() != null) {
527552
MinecraftTypes.writeVarInt(buf, component.getType().getId());
528-
529-
ByteBuf buf2 = Unpooled.buffer();
530-
component.write(buf2);
531-
MinecraftTypes.writeVarInt(buf, buf2.readableBytes());
532-
buf.writeBytes(buf2);
553+
MinecraftTypes.writeLengthPrefixed(buf, Integer.MAX_VALUE, component, (buf2, component2) -> component2.write(buf2));
533554
}
534555
}
535556
} else {

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/command/CommandNode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public class CommandNode {
2121
*/
2222
private final boolean executable;
2323

24+
/**
25+
* Whether restricted commands are allowed.
26+
*/
27+
private final boolean allowsRestricted;
28+
2429
/**
2530
* Child node indices.
2631
*/

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/command/CommandParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public enum CommandParser {
1818
ITEM_STACK,
1919
ITEM_PREDICATE,
2020
COLOR,
21+
HEX_COLOR,
2122
COMPONENT,
2223
STYLE,
2324
MESSAGE,
@@ -55,6 +56,7 @@ public enum CommandParser {
5556
LOOT_TABLE,
5657
LOOT_PREDICATE,
5758
LOOT_MODIFIER,
59+
DIALOG,
5860
UUID;
5961

6062
private static final CommandParser[] VALUES = values();

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/command/SuggestionType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
public enum SuggestionType {
1212
ASK_SERVER,
13-
ALL_RECIPES,
1413
AVAILABLE_SOUNDS,
1514
SUMMONABLE_ENTITIES;
1615

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/entity/EntityEvent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public enum EntityEvent {
6969
LIVING_EQUIPMENT_BREAK_BODY,
7070
SHAKE,
7171
DROWN_PARTICLES,
72-
SADDLE_BREAK;
72+
SADDLE_BREAK,
73+
RAVAGER_ROARED;
7374

7475
private static final EntityEvent[] VALUES = values();
7576

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/entity/attribute/AttributeType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum Builtin implements AttributeType {
4040
BLOCK_BREAK_SPEED("minecraft:block_break_speed", 1, 0, 1024),
4141
BLOCK_INTERACTION_RANGE("minecraft:block_interaction_range", 4.5, 0, 64),
4242
BURNING_TIME("minecraft:burning_time", 1, 0, 1024),
43+
CAMERA_DISTANCE("minecraft:camera_distance", 4, 0, 32),
4344
EXPLOSION_KNOCKBACK_RESISTANCE("minecraft:explosion_knockback_resistance", 0, 0, 1),
4445
ENTITY_INTERACTION_RANGE("minecraft:entity_interaction_range", 3, 0, 64),
4546
FALL_DAMAGE_MULTIPLIER("minecraft:fall_damage_multiplier", 1, 0, 100),
@@ -63,7 +64,9 @@ enum Builtin implements AttributeType {
6364
SUBMERGED_MINING_SPEED("minecraft:submerged_mining_speed", 0.2, 0, 20),
6465
SWEEPING_DAMAGE_RATIO("minecraft:sweeping_damage_ratio", 0, 0, 1),
6566
TEMPT_RANGE("minecraft:tempt_range", 10, 0, 2048),
66-
WATER_MOVEMENT_EFFICIENCY("minecraft:water_movement_efficiency", 0, 0, 1);
67+
WATER_MOVEMENT_EFFICIENCY("minecraft:water_movement_efficiency", 0, 0, 1),
68+
WAYPOINT_TRANSMIT_RANGE("minecraft:waypoint_transmit_range", 0, 0, 6.0E7),
69+
WAYPOINT_RECEIVE_RANGE("minecraft:waypoint_receive_range", 0, 0, 6.0E7);
6770

6871
private final Key identifier;
6972
private final double def;

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/entity/player/PlayerState.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package org.geysermc.mcprotocollib.protocol.data.game.entity.player;
22

33
public enum PlayerState {
4-
START_SNEAKING,
5-
STOP_SNEAKING,
64
LEAVE_BED,
75
START_SPRINTING,
86
STOP_SPRINTING,

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/entity/type/EntityType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public enum EntityType {
5959
FROG,
6060
FURNACE_MINECART,
6161
GHAST,
62+
HAPPY_GHAST,
6263
GIANT,
6364
GLOW_ITEM_FRAME,
6465
GLOW_SQUID,

0 commit comments

Comments
 (0)