Skip to content

Commit 90d69dd

Browse files
committed
25w41a
1 parent b521281 commit 90d69dd

File tree

15 files changed

+248
-23
lines changed

15 files changed

+248
-23
lines changed

protocol/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
jacoco
66
}
77

8-
version = "1.21.9-SNAPSHOT"
8+
version = "1.21.11-SNAPSHOT"
99
description = "MCProtocolLib is a simple library for communicating with Minecraft clients and servers."
1010

1111
dependencies {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@
231231

232232
public class MinecraftCodec {
233233
public static final PacketCodec CODEC = PacketCodec.builder()
234-
.protocolVersion(773)
235-
.minecraftVersion("1.21.9")
234+
.protocolVersion((1 << 30) | 273)
235+
.minecraftVersion("25w41a")
236236
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
237237
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
238238
)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public enum Effect {
3939
WIND_CHARGED,
4040
WEAVING,
4141
OOZING,
42-
INFESTED;
42+
INFESTED,
43+
BREATH_OF_THE_NAUTILUS;
4344

4445
public static final Effect[] VALUES = values();
4546

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ public enum PlayerAction {
77
DROP_ITEM_STACK,
88
DROP_ITEM,
99
RELEASE_USE_ITEM,
10-
SWAP_HANDS;
10+
SWAP_HANDS,
11+
STAB;
1112

1213
private static final PlayerAction[] VALUES = values();
1314

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public enum EntityType {
9090
MINECART,
9191
MOOSHROOM,
9292
MULE,
93+
NAUTILUS,
9394
OAK_BOAT,
9495
OAK_CHEST_BOAT,
9596
OCELOT,
@@ -152,6 +153,7 @@ public enum EntityType {
152153
ZOGLIN,
153154
ZOMBIE,
154155
ZOMBIE_HORSE,
156+
ZOMBIE_NAUTILUS,
155157
ZOMBIE_VILLAGER,
156158
ZOMBIFIED_PIGLIN,
157159
PLAYER,

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Consumable.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ public enum ItemUseAnimation {
2121
DRINK,
2222
BLOCK,
2323
BOW,
24-
SPEAR,
24+
TRIDENT,
2525
CROSSBOW,
2626
SPYGLASS,
2727
TOOT_HORN,
2828
BRUSH,
29-
BUNDLE;
29+
BUNDLE,
30+
SPEAR;
3031

3132
private static final ItemUseAnimation[] VALUES = values();
3233

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
22

33
import lombok.Builder;
4+
import org.cloudburstmc.nbt.NbtMap;
45

56
import java.util.Map;
67

78
@Builder(toBuilder = true)
8-
public record DataComponentMatchers(Map<DataComponentType<?>, DataComponent<?, ?>> exactMatchers, int[] partialMatchers) {
9+
public record DataComponentMatchers(Map<DataComponentType<?>, DataComponent<?, ?>> exactMatchers, Map<PredicateType, NbtMap> partialMatchers) {
10+
public DataComponentMatchers(Map<DataComponentType<?>, DataComponent<?, ?>> exactMatchers, Map<PredicateType, NbtMap> partialMatchers) {
11+
this.exactMatchers = Map.copyOf(exactMatchers);
12+
this.partialMatchers = Map.copyOf(partialMatchers);
13+
}
14+
15+
@Builder(toBuilder = true)
16+
public record PredicateType(boolean isPredicate, int id) {
17+
}
918
}

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/DataComponentTypes.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public class DataComponentTypes {
3131
public static final IntComponentType MAX_DAMAGE = register(id -> new IntComponentType(id, "max_damage", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
3232
public static final IntComponentType DAMAGE = register(id -> new IntComponentType(id, "damage", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
3333
public static final DataComponentType<Unit> UNBREAKABLE = register(id -> new DataComponentType<>(id, "unbreakable", unitReader(), unitWriter(), ObjectDataComponent::new));
34+
public static final DataComponentType<UseEffects> USE_EFFECTS = register(id -> new DataComponentType<>(id, "use_effects", ItemTypes::readUseEffects, ItemTypes::writeUseEffects, ObjectDataComponent::new));
3435
public static final DataComponentType<Component> CUSTOM_NAME = register(id -> new DataComponentType<>(id, "custom_name", MinecraftTypes::readComponent, MinecraftTypes::writeComponent, ObjectDataComponent::new));
36+
public static final DataComponentType<Float> MINIMUM_ATTACK_CHARGE = register(id -> new DataComponentType<>(id, "minimum_attack_charge", ByteBuf::readFloat, ByteBuf::writeFloat, ObjectDataComponent::new));
37+
public static final DataComponentType<Holder<Key>> DAMAGE_TYPE = register(id -> new DataComponentType<>(id, "damage_type", ItemTypes::readDamageType, ItemTypes::writeDamageType, ObjectDataComponent::new));
3538
public static final DataComponentType<Component> ITEM_NAME = register(id -> new DataComponentType<>(id, "item_name", MinecraftTypes::readComponent, MinecraftTypes::writeComponent, ObjectDataComponent::new));
3639
public static final DataComponentType<Key> ITEM_MODEL = register(id -> new DataComponentType<>(id, "item_model", MinecraftTypes::readResourceLocation, MinecraftTypes::writeResourceLocation, ObjectDataComponent::new));
3740
public static final DataComponentType<List<Component>> LORE = register(id -> new DataComponentType<>(id, "lore", listReader(MinecraftTypes::readComponent), listWriter(MinecraftTypes::writeComponent), ObjectDataComponent::new));
@@ -60,6 +63,9 @@ public class DataComponentTypes {
6063
public static final DataComponentType<Key> TOOLTIP_STYLE = register(id -> new DataComponentType<>(id, "tooltip_style", MinecraftTypes::readResourceLocation, MinecraftTypes::writeResourceLocation, ObjectDataComponent::new));
6164
public static final DataComponentType<List<ConsumeEffect>> DEATH_PROTECTION = register(id -> new DataComponentType<>(id, "death_protection", listReader(ItemTypes::readConsumeEffect), listWriter(ItemTypes::writeConsumeEffect), ObjectDataComponent::new));
6265
public static final DataComponentType<BlocksAttacks> BLOCKS_ATTACKS = register(id -> new DataComponentType<>(id, "blocks_attacks", ItemTypes::readBlocksAttacks, ItemTypes::writeBlocksAttacks, ObjectDataComponent::new));
66+
public static final DataComponentType<PiercingWeapon> PIERCING_WEAPON = register(id -> new DataComponentType<>(id, "piercing_weapon", ItemTypes::readPiercingWeapon, ItemTypes::writePiercingWeapon, ObjectDataComponent::new));
67+
public static final DataComponentType<KineticWeapon> KINETIC_WEAPON = register(id -> new DataComponentType<>(id, "kinetic_weapon", ItemTypes::readKineticWeapon, ItemTypes::writeKineticWeapon, ObjectDataComponent::new));
68+
public static final DataComponentType<SwingAnimation> SWING_ANIMATION = register(id -> new DataComponentType<>(id, "swing_animation", ItemTypes::readSwingAnimation, ItemTypes::writeSwingAnimation, ObjectDataComponent::new));
6369
public static final DataComponentType<ItemEnchantments> STORED_ENCHANTMENTS = register(id -> new DataComponentType<>(id, "stored_enchantments", ItemTypes::readItemEnchantments, ItemTypes::writeItemEnchantments, ObjectDataComponent::new));
6470
public static final IntComponentType DYED_COLOR = register(id -> new IntComponentType(id, "dyed_color", ByteBuf::readInt, ByteBuf::writeInt, IntDataComponent::new));
6571
public static final IntComponentType MAP_COLOR = register(id -> new IntComponentType(id, "map_color", ByteBuf::readInt, ByteBuf::writeInt, IntDataComponent::new));

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemTypes.java

Lines changed: 128 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,36 @@ public static <T> void writeFilterable(ByteBuf buf, Filterable<T> filterable, Bi
3636
MinecraftTypes.writeNullable(buf, filterable.getOptional(), writer);
3737
}
3838

39+
public static UseEffects readUseEffects(ByteBuf buf) {
40+
boolean canSprint = buf.readBoolean();
41+
float speedMultiplier = buf.readFloat();
42+
43+
return new UseEffects(canSprint, speedMultiplier);
44+
}
45+
46+
public static void writeUseEffects(ByteBuf buf, UseEffects useEffects) {
47+
buf.writeBoolean(useEffects.canSprint());
48+
buf.writeFloat(useEffects.speedMultiplier());
49+
}
50+
51+
public static Holder<Key> readDamageType(ByteBuf buf) {
52+
if (buf.readBoolean()) {
53+
return Holder.ofId(MinecraftTypes.readVarInt(buf));
54+
} else {
55+
return Holder.ofCustom(MinecraftTypes.readResourceLocation(buf));
56+
}
57+
}
58+
59+
public static void writeDamageType(ByteBuf buf, Holder<Key> variant) {
60+
if (variant.isId()) {
61+
buf.writeBoolean(true);
62+
MinecraftTypes.writeVarInt(buf, variant.id());
63+
} else {
64+
buf.writeBoolean(false);
65+
MinecraftTypes.writeResourceLocation(buf, variant.custom());
66+
}
67+
}
68+
3969
public static ItemEnchantments readItemEnchantments(ByteBuf buf) {
4070
Map<Integer, Integer> enchantments = new HashMap<>();
4171
int enchantmentCount = MinecraftTypes.readVarInt(buf);
@@ -106,10 +136,16 @@ public static void writeBlockPredicate(ByteBuf buf, AdventureModePredicate.Block
106136

107137
public static DataComponentMatchers readDataComponentMatchers(ByteBuf buf) {
108138
Map<DataComponentType<?>, DataComponent<?, ?>> exactMatchers = MinecraftTypes.readExactComponentMatcher(buf);
139+
Map<DataComponentMatchers.PredicateType, NbtMap> partialMatchers = new HashMap<>();
109140

110-
int[] partialMatchers = new int[MinecraftTypes.readVarInt(buf)];
111-
for (int i = 0; i < partialMatchers.length; i++) {
112-
partialMatchers[i] = MinecraftTypes.readVarInt(buf);
141+
int count = MinecraftTypes.readVarInt(buf);
142+
if (count > 64) {
143+
throw new IllegalArgumentException(count + " elements exceeds max size of: " + 64);
144+
}
145+
146+
for (int i = 0; i < count; i++) {
147+
DataComponentMatchers.PredicateType type = new DataComponentMatchers.PredicateType(buf.readBoolean(), MinecraftTypes.readVarInt(buf));
148+
partialMatchers.put(type, MinecraftTypes.readCompoundTag(buf));
113149
}
114150

115151
return new DataComponentMatchers(exactMatchers, partialMatchers);
@@ -118,9 +154,16 @@ public static DataComponentMatchers readDataComponentMatchers(ByteBuf buf) {
118154
public static void writeDataComponentMatchers(ByteBuf buf, DataComponentMatchers matchers) {
119155
MinecraftTypes.writeExactComponentMatcher(buf, matchers.exactMatchers());
120156

121-
MinecraftTypes.writeVarInt(buf, matchers.partialMatchers().length);
122-
for (int id : matchers.partialMatchers()) {
123-
MinecraftTypes.writeVarInt(buf, id);
157+
int count = matchers.partialMatchers().size();
158+
if (count > 64) {
159+
throw new IllegalArgumentException(count + " elements exceeds max size of: " + 64);
160+
}
161+
162+
MinecraftTypes.writeVarInt(buf, count);
163+
for (Map.Entry<DataComponentMatchers.PredicateType, NbtMap> entry : matchers.partialMatchers().entrySet()) {
164+
buf.writeBoolean(entry.getKey().isPredicate());
165+
MinecraftTypes.writeVarInt(buf, entry.getKey().id());
166+
MinecraftTypes.writeAnyTag(buf, entry.getValue());
124167
}
125168
}
126169

@@ -229,6 +272,85 @@ public static void writeBlocksAttacks(ByteBuf buf, BlocksAttacks blocksAttacks)
229272
MinecraftTypes.writeNullable(buf, blocksAttacks.disableSound(), MinecraftTypes::writeSound);
230273
}
231274

275+
public static PiercingWeapon readPiercingWeapon(ByteBuf buf) {
276+
float minReach = buf.readFloat();
277+
float maxReach = buf.readFloat();
278+
float hitboxMargin = buf.readFloat();
279+
boolean dealsKnockback = buf.readBoolean();
280+
boolean dismounts = buf.readBoolean();
281+
Sound sound = MinecraftTypes.readNullable(buf, MinecraftTypes::readSound);
282+
Sound hitSound = MinecraftTypes.readNullable(buf, MinecraftTypes::readSound);
283+
284+
return new PiercingWeapon(minReach, maxReach, hitboxMargin, dealsKnockback, dismounts, sound, hitSound);
285+
}
286+
287+
public static void writePiercingWeapon(ByteBuf buf, PiercingWeapon piercingWeapon) {
288+
buf.writeFloat(piercingWeapon.minReach());
289+
buf.writeFloat(piercingWeapon.maxReach());
290+
buf.writeFloat(piercingWeapon.hitboxMargin());
291+
buf.writeBoolean(piercingWeapon.dealsKnockback());
292+
buf.writeBoolean(piercingWeapon.dismounts());
293+
MinecraftTypes.writeNullable(buf, piercingWeapon.sound(), MinecraftTypes::writeSound);
294+
MinecraftTypes.writeNullable(buf, piercingWeapon.hitSound(), MinecraftTypes::writeSound);
295+
}
296+
297+
public static KineticWeapon readKineticWeapon(ByteBuf buf) {
298+
float minReach = buf.readFloat();
299+
float maxReach = buf.readFloat();
300+
float hitboxMargin = buf.readFloat();
301+
int delayTicks = MinecraftTypes.readVarInt(buf);
302+
KineticWeapon.Condition dismountConditions = MinecraftTypes.readNullable(buf, ItemTypes::readKineticCondition);
303+
KineticWeapon.Condition knockbackConditions = MinecraftTypes.readNullable(buf, ItemTypes::readKineticCondition);
304+
KineticWeapon.Condition damageConditions = MinecraftTypes.readNullable(buf, ItemTypes::readKineticCondition);
305+
float forwardMovement = buf.readFloat();
306+
float damageMultiplier = buf.readFloat();
307+
Sound sound = MinecraftTypes.readNullable(buf, MinecraftTypes::readSound);
308+
Sound hitSound = MinecraftTypes.readNullable(buf, MinecraftTypes::readSound);
309+
310+
return new KineticWeapon(minReach, maxReach, hitboxMargin, delayTicks, dismountConditions,
311+
knockbackConditions, damageConditions, forwardMovement, damageMultiplier, sound, hitSound);
312+
}
313+
314+
public static void writeKineticWeapon(ByteBuf buf, KineticWeapon kineticWeapon) {
315+
buf.writeFloat(kineticWeapon.minReach());
316+
buf.writeFloat(kineticWeapon.maxReach());
317+
buf.writeFloat(kineticWeapon.hitboxMargin());
318+
MinecraftTypes.writeVarInt(buf, kineticWeapon.delayTicks());
319+
MinecraftTypes.writeNullable(buf, kineticWeapon.dismountConditions(), ItemTypes::writeKineticCondition);
320+
MinecraftTypes.writeNullable(buf, kineticWeapon.knockbackConditions(), ItemTypes::writeKineticCondition);
321+
MinecraftTypes.writeNullable(buf, kineticWeapon.damageConditions(), ItemTypes::writeKineticCondition);
322+
buf.writeFloat(kineticWeapon.forwardMovement());
323+
buf.writeFloat(kineticWeapon.damageMultiplier());
324+
MinecraftTypes.writeNullable(buf, kineticWeapon.sound(), MinecraftTypes::writeSound);
325+
MinecraftTypes.writeNullable(buf, kineticWeapon.hitSound(), MinecraftTypes::writeSound);
326+
}
327+
328+
public static KineticWeapon.Condition readKineticCondition(ByteBuf buf) {
329+
int maxDurationTicks = MinecraftTypes.readVarInt(buf);
330+
float minSpeed = buf.readFloat();
331+
float minRelativeSpeed = buf.readFloat();
332+
333+
return new KineticWeapon.Condition(maxDurationTicks, minSpeed, minRelativeSpeed);
334+
}
335+
336+
public static void writeKineticCondition(ByteBuf buf, KineticWeapon.Condition condition) {
337+
MinecraftTypes.writeVarInt(buf, condition.maxDurationTicks());
338+
buf.writeFloat(condition.minSpeed());
339+
buf.writeFloat(condition.minRelativeSpeed());
340+
}
341+
342+
public static SwingAnimation readSwingAnimation(ByteBuf buf) {
343+
SwingAnimation.Type type = SwingAnimation.Type.from(MinecraftTypes.readVarInt(buf));
344+
int duration = MinecraftTypes.readVarInt(buf);
345+
346+
return new SwingAnimation(type, duration);
347+
}
348+
349+
public static void writeSwingAnimation(ByteBuf buf, SwingAnimation swingAnimation) {
350+
MinecraftTypes.writeVarInt(buf, swingAnimation.type().ordinal());
351+
MinecraftTypes.writeVarInt(buf, swingAnimation.duration());
352+
}
353+
232354
public static ItemAttributeModifiers readItemAttributeModifiers(ByteBuf buf) {
233355
List<ItemAttributeModifiers.Entry> modifiers = MinecraftTypes.readList(buf, (input) -> {
234356
int attribute = MinecraftTypes.readVarInt(input);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
2+
3+
import lombok.Builder;
4+
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;
5+
import org.jetbrains.annotations.Nullable;
6+
7+
@Builder(toBuilder = true)
8+
public record KineticWeapon(float minReach, float maxReach, float hitboxMargin, int delayTicks,
9+
@Nullable Condition dismountConditions, @Nullable Condition knockbackConditions,
10+
@Nullable Condition damageConditions, float forwardMovement, float damageMultiplier,
11+
@Nullable Sound sound, @Nullable Sound hitSound) {
12+
13+
@Builder(toBuilder = true)
14+
public record Condition(int maxDurationTicks, float minSpeed, float minRelativeSpeed) {
15+
}
16+
}

0 commit comments

Comments
 (0)