Skip to content

Commit 6d18428

Browse files
committed
25w02a
1 parent b40365e commit 6d18428

File tree

17 files changed

+78
-51
lines changed

17 files changed

+78
-51
lines changed

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.4-SNAPSHOT"
6+
version = "1.21.5-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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@
9292
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetExperiencePacket;
9393
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
9494
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHeldSlotPacket;
95-
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
96-
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddExperienceOrbPacket;
95+
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAddEntityPacket;
9796
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerClosePacket;
9897
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetContentPacket;
9998
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetDataPacket;
@@ -216,8 +215,8 @@
216215

217216
public class MinecraftCodec {
218217
public static final PacketCodec CODEC = PacketCodec.builder()
219-
.protocolVersion(769)
220-
.minecraftVersion("1.21.4")
218+
.protocolVersion((1 << 30) | 229)
219+
.minecraftVersion("25w02a")
221220
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
222221
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
223222
)
@@ -267,7 +266,6 @@ public class MinecraftCodec {
267266
).state(ProtocolState.GAME, MinecraftPacketRegistry.builder()
268267
.registerClientboundPacket(ClientboundDelimiterPacket.class, ClientboundDelimiterPacket::new)
269268
.registerClientboundPacket(ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new)
270-
.registerClientboundPacket(ClientboundAddExperienceOrbPacket.class, ClientboundAddExperienceOrbPacket::new)
271269
.registerClientboundPacket(ClientboundAnimatePacket.class, ClientboundAnimatePacket::new)
272270
.registerClientboundPacket(ClientboundAwardStatsPacket.class, ClientboundAwardStatsPacket::new)
273271
.registerClientboundPacket(ClientboundBlockChangedAckPacket.class, ClientboundBlockChangedAckPacket::new)

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
4545
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
4646
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PaintingVariant;
47+
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PigVariant;
4748
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
4849
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.SnifferState;
4950
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.VillagerData;
@@ -630,6 +631,23 @@ public static void writeWolfVariant(ByteBuf buf, Holder<WolfVariant> variantHold
630631
});
631632
}
632633

634+
public static Holder<PigVariant> readPigVariant(ByteBuf buf) {
635+
return MinecraftTypes.readHolder(buf, input -> {
636+
int modelId = MinecraftTypes.readVarInt(input);
637+
Key texture = MinecraftTypes.readResourceLocation(input);
638+
HolderSet biomes = MinecraftTypes.readNullable(input, MinecraftTypes::readHolderSet);
639+
return new PigVariant(modelId, texture, biomes);
640+
});
641+
}
642+
643+
public static void writePigVariant(ByteBuf buf, Holder<PigVariant> variantHolder) {
644+
MinecraftTypes.writeHolder(buf, variantHolder, (output, variant) -> {
645+
MinecraftTypes.writeVarInt(buf, variant.modelId());
646+
MinecraftTypes.writeResourceLocation(buf, variant.texture());
647+
MinecraftTypes.writeNullable(buf, variant.biomes(), MinecraftTypes::writeHolderSet);
648+
});
649+
}
650+
633651
public static Holder<PaintingVariant> readPaintingVariant(ByteBuf buf) {
634652
return MinecraftTypes.readHolder(buf, input -> {
635653
return new PaintingVariant(MinecraftTypes.readVarInt(input), MinecraftTypes.readVarInt(input), MinecraftTypes.readResourceLocation(input),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class MetadataType<T> {
4141
public static final MetadataType<Vector3i> POSITION = new MetadataType<>(MinecraftTypes::readPosition, MinecraftTypes::writePosition, ObjectEntityMetadata::new);
4242
public static final MetadataType<Optional<Vector3i>> OPTIONAL_POSITION = new MetadataType<>(optionalReader(MinecraftTypes::readPosition), optionalWriter(MinecraftTypes::writePosition), ObjectEntityMetadata::new);
4343
public static final MetadataType<Direction> DIRECTION = new MetadataType<>(MinecraftTypes::readDirection, MinecraftTypes::writeDirection, ObjectEntityMetadata::new);
44-
public static final MetadataType<Optional<UUID>> OPTIONAL_UUID = new MetadataType<>(optionalReader(MinecraftTypes::readUUID), optionalWriter(MinecraftTypes::writeUUID), ObjectEntityMetadata::new);
44+
public static final MetadataType<Optional<UUID>> OPTIONAL_LIVING_ENTITY_REFERENCE = new MetadataType<>(optionalReader(MinecraftTypes::readUUID), optionalWriter(MinecraftTypes::writeUUID), ObjectEntityMetadata::new);
4545
public static final IntMetadataType BLOCK_STATE = new IntMetadataType(MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new);
4646
public static final IntMetadataType OPTIONAL_BLOCK_STATE = new IntMetadataType(MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new);
4747
public static final MetadataType<NbtMap> NBT_TAG = new MetadataType<>(MinecraftTypes::readCompoundTag, MinecraftTypes::writeAnyTag, ObjectEntityMetadata::new);
@@ -53,6 +53,7 @@ public class MetadataType<T> {
5353
public static final IntMetadataType CAT_VARIANT = new IntMetadataType(MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new);
5454
public static final MetadataType<Holder<WolfVariant>> WOLF_VARIANT = new MetadataType<>(MinecraftTypes::readWolfVariant, MinecraftTypes::writeWolfVariant, ObjectEntityMetadata::new);
5555
public static final IntMetadataType FROG_VARIANT = new IntMetadataType(MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new);
56+
public static final MetadataType<Holder<PigVariant>> PIG_VARIANT = new MetadataType<>(MinecraftTypes::readPigVariant, MinecraftTypes::writePigVariant, ObjectEntityMetadata::new);
5657
public static final MetadataType<Optional<GlobalPos>> OPTIONAL_GLOBAL_POS = new MetadataType<>(optionalReader(MinecraftTypes::readGlobalPos), optionalWriter(MinecraftTypes::writeGlobalPos), ObjectEntityMetadata::new);
5758
public static final MetadataType<Holder<PaintingVariant>> PAINTING_VARIANT = new MetadataType<>(MinecraftTypes::readPaintingVariant, MinecraftTypes::writePaintingVariant, ObjectEntityMetadata::new);
5859
public static final MetadataType<SnifferState> SNIFFER_STATE = new MetadataType<>(MinecraftTypes::readSnifferState, MinecraftTypes::writeSnifferState, ObjectEntityMetadata::new);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
2+
3+
import net.kyori.adventure.key.Key;
4+
import org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet;
5+
import org.jetbrains.annotations.Nullable;
6+
7+
public record PigVariant(int modelId, Key texture, @Nullable HolderSet biomes) {
8+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class DataComponentType<T> {
4848
public static final DataComponentType<UseCooldown> USE_COOLDOWN = new DataComponentType<>("use_cooldown", ItemTypes::readUseCooldown, ItemTypes::writeUseCooldown, ObjectDataComponent::new);
4949
public static final DataComponentType<Key> DAMAGE_RESISTANT = new DataComponentType<>("damage_resistant", MinecraftTypes::readResourceLocation, MinecraftTypes::writeResourceLocation, ObjectDataComponent::new);
5050
public static final DataComponentType<ToolData> TOOL = new DataComponentType<>("tool", ItemTypes::readToolData, ItemTypes::writeToolData, ObjectDataComponent::new);
51+
public static final DataComponentType<Weapon> WEAPON = new DataComponentType<>("weapon", ItemTypes::readWeapon, ItemTypes::writeWeapon, ObjectDataComponent::new);
5152
public static final IntComponentType ENCHANTABLE = new IntComponentType("enchantable", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
5253
public static final DataComponentType<Equippable> EQUIPPABLE = new DataComponentType<>("equippable", ItemTypes::readEquippable, ItemTypes::writeEquippable, ObjectDataComponent::new);
5354
public static final DataComponentType<HolderSet> REPAIRABLE = new DataComponentType<>("repairable", MinecraftTypes::readHolderSet, MinecraftTypes::writeHolderSet, ObjectDataComponent::new);
@@ -63,6 +64,7 @@ public class DataComponentType<T> {
6364
public static final DataComponentType<List<ItemStack>> CHARGED_PROJECTILES = new DataComponentType<>("charged_projectiles", listReader(MinecraftTypes::readItemStack), listWriter(MinecraftTypes::writeItemStack), ObjectDataComponent::new);
6465
public static final DataComponentType<List<ItemStack>> BUNDLE_CONTENTS = new DataComponentType<>("bundle_contents", listReader(MinecraftTypes::readItemStack), listWriter(MinecraftTypes::writeItemStack), ObjectDataComponent::new);
6566
public static final DataComponentType<PotionContents> POTION_CONTENTS = new DataComponentType<>("potion_contents", ItemTypes::readPotionContents, ItemTypes::writePotionContents, ObjectDataComponent::new);
67+
public static final DataComponentType<Float> POTION_DURATION_SCALE = new DataComponentType<>("potion_duration_scale", ByteBuf::readFloat, ByteBuf::writeFloat, ObjectDataComponent::new);
6668
public static final DataComponentType<List<SuspiciousStewEffect>> SUSPICIOUS_STEW_EFFECTS = new DataComponentType<>("suspicious_stew_effects", listReader(ItemTypes::readStewEffect), listWriter(ItemTypes::writeStewEffect), ObjectDataComponent::new);
6769
public static final DataComponentType<WritableBookContent> WRITABLE_BOOK_CONTENT = new DataComponentType<>("writable_book_content", ItemTypes::readWritableBookContent, ItemTypes::writeWritableBookContent, ObjectDataComponent::new);
6870
public static final DataComponentType<WrittenBookContent> WRITTEN_BOOK_CONTENT = new DataComponentType<>("written_book_content", ItemTypes::readWrittenBookContent, ItemTypes::writeWrittenBookContent, ObjectDataComponent::new);

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ public static ToolData readToolData(ByteBuf buf) {
129129

130130
float defaultMiningSpeed = buf.readFloat();
131131
int damagePerBlock = MinecraftTypes.readVarInt(buf);
132-
return new ToolData(rules, defaultMiningSpeed, damagePerBlock);
132+
boolean canDestroyBlocksInCreative = buf.readBoolean();
133+
return new ToolData(rules, defaultMiningSpeed, damagePerBlock, canDestroyBlocksInCreative);
133134
}
134135

135136
public static void writeToolData(ByteBuf buf, ToolData data) {
@@ -141,6 +142,18 @@ public static void writeToolData(ByteBuf buf, ToolData data) {
141142

142143
buf.writeFloat(data.getDefaultMiningSpeed());
143144
MinecraftTypes.writeVarInt(buf, data.getDamagePerBlock());
145+
buf.writeBoolean(data.isCanDestroyBlocksInCreative());
146+
}
147+
148+
public static Weapon readWeapon(ByteBuf buf) {
149+
int damagePerAttack = MinecraftTypes.readVarInt(buf);
150+
boolean canDisableBlocking = buf.readBoolean();
151+
return new Weapon(damagePerAttack, canDisableBlocking);
152+
}
153+
154+
public static void writeWeapon(ByteBuf buf, Weapon weapon) {
155+
MinecraftTypes.writeVarInt(buf, weapon.damagePerAttack());
156+
buf.writeBoolean(weapon.canDisableBlocking());
144157
}
145158

146159
public static Equippable readEquippable(ByteBuf buf) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class ToolData {
1313
private final List<Rule> rules;
1414
private final float defaultMiningSpeed;
1515
private final int damagePerBlock;
16+
private final boolean canDestroyBlocksInCreative;
1617

1718
@Data
1819
@AllArgsConstructor
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
2+
3+
public record Weapon(int damagePerAttack, boolean canDisableBlocking) {
4+
}

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/ParticleType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public enum ParticleType {
3636
INFESTED,
3737
CHERRY_LEAVES,
3838
PALE_OAK_LEAVES,
39+
TINTED_LEAVES,
3940
SCULK_SOUL,
4041
SCULK_CHARGE,
4142
SCULK_CHARGE_POP,

0 commit comments

Comments
 (0)