Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion protocol/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
jacoco
}

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

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetContentPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetDataPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetSlotPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundHorseScreenOpenPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundMountScreenOpenPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundMerchantOffersPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundOpenBookPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundOpenScreenPacket;
Expand Down Expand Up @@ -231,8 +231,8 @@

public class MinecraftCodec {
public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion(773)
.minecraftVersion("1.21.9")
.protocolVersion(774)
.minecraftVersion("1.21.11")
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
)
Expand Down Expand Up @@ -325,7 +325,7 @@ public class MinecraftCodec {
.registerClientboundPacket(ClientboundForgetLevelChunkPacket.class, ClientboundForgetLevelChunkPacket::new)
.registerClientboundPacket(ClientboundGameEventPacket.class, ClientboundGameEventPacket::new)
.registerClientboundPacket(ClientboundGameTestHighlightPosPacket.class, ClientboundGameTestHighlightPosPacket::new)
.registerClientboundPacket(ClientboundHorseScreenOpenPacket.class, ClientboundHorseScreenOpenPacket::new)
.registerClientboundPacket(ClientboundMountScreenOpenPacket.class, ClientboundMountScreenOpenPacket::new)
.registerClientboundPacket(ClientboundHurtAnimationPacket.class, ClientboundHurtAnimationPacket::new)
.registerClientboundPacket(ClientboundInitializeBorderPacket.class, ClientboundInitializeBorderPacket::new)
.registerClientboundPacket(ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.CopperGolemState;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.HumanoidArm;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataTypes;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PaintingVariant;
Expand Down Expand Up @@ -837,6 +838,24 @@ public static void writeChickenVariant(ByteBuf buf, Holder<Key> variant) {
}
}

public static Holder<Key> readZombieNautilusVariant(ByteBuf buf) {
if (buf.readBoolean()) {
return Holder.ofId(MinecraftTypes.readVarInt(buf));
} else {
return Holder.ofCustom(MinecraftTypes.readResourceLocation(buf));
}
}

public static void writeZombieNautilusVariant(ByteBuf buf, Holder<Key> variant) {
if (variant.isId()) {
buf.writeBoolean(true);
MinecraftTypes.writeVarInt(buf, variant.id());
} else {
buf.writeBoolean(false);
MinecraftTypes.writeResourceLocation(buf, variant.custom());
}
}

public static Holder<PaintingVariant> readPaintingVariant(ByteBuf buf) {
return MinecraftTypes.readHolder(buf, input -> {
return new PaintingVariant(MinecraftTypes.readVarInt(input), MinecraftTypes.readVarInt(input), MinecraftTypes.readResourceLocation(input),
Expand Down Expand Up @@ -886,6 +905,14 @@ public static void writeWeatheringCopperState(ByteBuf buf, WeatheringCopperState
MinecraftTypes.writeEnum(buf, state);
}

public static HumanoidArm readHumanoidArm(ByteBuf buf) {
return HumanoidArm.from(MinecraftTypes.readVarInt(buf));
}

public static void writeHumanoidArm(ByteBuf buf, HumanoidArm arm) {
MinecraftTypes.writeVarInt(buf, arm.ordinal());
}

private static void writeEnum(ByteBuf buf, Enum<?> e) {
MinecraftTypes.writeVarInt(buf, e.ordinal());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public enum Effect {
WIND_CHARGED,
WEAVING,
OOZING,
INFESTED;
INFESTED,
BREATH_OF_THE_NAUTILUS;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;

public enum HumanoidArm {
LEFT,
RIGHT;

private static final HumanoidArm[] VALUES = values();

public static HumanoidArm from(int id) {
return id >= 0 & id < VALUES.length ? VALUES[id] : VALUES[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class MetadataTypes {
public static final IntMetadataType FROG_VARIANT = register(id -> new IntMetadataType(id, MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new));
public static final IntMetadataType PIG_VARIANT = register(id -> new IntMetadataType(id, MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new));
public static final IntMetadataType CHICKEN_VARIANT = register(id -> new IntMetadataType(id, MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new));
public static final IntMetadataType ZOMBIE_NAUTILUS_VARIANT = register(id -> new IntMetadataType(id, MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntEntityMetadata::new));
public static final MetadataType<Optional<GlobalPos>> OPTIONAL_GLOBAL_POS = register(id -> new MetadataType<>(id, optionalReader(MinecraftTypes::readGlobalPos), optionalWriter(MinecraftTypes::writeGlobalPos), ObjectEntityMetadata::new));
public static final MetadataType<Holder<PaintingVariant>> PAINTING_VARIANT = register(id -> new MetadataType<>(id, MinecraftTypes::readPaintingVariant, MinecraftTypes::writePaintingVariant, ObjectEntityMetadata::new));
public static final MetadataType<SnifferState> SNIFFER_STATE = register(id -> new MetadataType<>(id, MinecraftTypes::readSnifferState, MinecraftTypes::writeSnifferState, ObjectEntityMetadata::new));
Expand All @@ -66,6 +67,7 @@ public class MetadataTypes {
public static final MetadataType<Vector3f> VECTOR3 = register(id -> new MetadataType<>(id, MinecraftTypes::readRotation, MinecraftTypes::writeRotation, ObjectEntityMetadata::new));
public static final MetadataType<Quaternionf> QUATERNION = register(id -> new MetadataType<>(id, MinecraftTypes::readQuaternion, MinecraftTypes::writeQuaternion, ObjectEntityMetadata::new));
public static final MetadataType<ResolvableProfile> RESOLVABLE_PROFILE = register(id -> new MetadataType<>(id, MinecraftTypes::readResolvableProfile, MinecraftTypes::writeResolvableProfile, ObjectEntityMetadata::new));
public static final MetadataType<HumanoidArm> HUMANOID_ARM = register(id -> new MetadataType<>(id, MinecraftTypes::readHumanoidArm, MinecraftTypes::writeHumanoidArm, ObjectEntityMetadata::new));

public static <T extends MetadataType<?>> T register(Int2ObjectFunction<T> factory) {
T value = factory.apply(VALUES.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public enum PlayerAction {
DROP_ITEM_STACK,
DROP_ITEM,
RELEASE_USE_ITEM,
SWAP_HANDS;
SWAP_HANDS,
STAB;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum EntityType {
BREEZE,
BREEZE_WIND_CHARGE(true),
CAMEL,
CAMEL_HUSK,
CAT,
CAVE_SPIDER,
CHERRY_BOAT,
Expand Down Expand Up @@ -90,6 +91,7 @@ public enum EntityType {
MINECART,
MOOSHROOM,
MULE,
NAUTILUS,
OAK_BOAT,
OAK_CHEST_BOAT,
OCELOT,
Expand All @@ -98,6 +100,7 @@ public enum EntityType {
PALE_OAK_BOAT,
PALE_OAK_CHEST_BOAT,
PANDA,
PARCHED,
PARROT,
PHANTOM,
PIG,
Expand Down Expand Up @@ -152,6 +155,7 @@ public enum EntityType {
ZOGLIN,
ZOMBIE,
ZOMBIE_HORSE,
ZOMBIE_NAUTILUS,
ZOMBIE_VILLAGER,
ZOMBIFIED_PIGLIN,
PLAYER,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;

import lombok.Builder;

@Builder(toBuilder = true)
public record AttackRange(float minRange, float maxRange, float minCreativeRange,
float maxCreativeRange, float hitboxMargin, float mobFactor) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ public enum ItemUseAnimation {
DRINK,
BLOCK,
BOW,
SPEAR,
TRIDENT,
CROSSBOW,
SPYGLASS,
TOOT_HORN,
BRUSH,
BUNDLE;
BUNDLE,
SPEAR;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;

import lombok.Builder;
import org.cloudburstmc.nbt.NbtMap;

import java.util.Map;

@Builder(toBuilder = true)
public record DataComponentMatchers(Map<DataComponentType<?>, DataComponent<?, ?>> exactMatchers, int[] partialMatchers) {
public record DataComponentMatchers(Map<DataComponentType<?>, DataComponent<?, ?>> exactMatchers, Map<PredicateType, NbtMap> partialMatchers) {
public DataComponentMatchers(Map<DataComponentType<?>, DataComponent<?, ?>> exactMatchers, Map<PredicateType, NbtMap> partialMatchers) {
this.exactMatchers = Map.copyOf(exactMatchers);
this.partialMatchers = Map.copyOf(partialMatchers);
}

@Builder(toBuilder = true)
public record PredicateType(boolean isPredicate, int id) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class DataComponentTypes {
public static final IntComponentType MAX_DAMAGE = register(id -> new IntComponentType(id, "max_damage", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
public static final IntComponentType DAMAGE = register(id -> new IntComponentType(id, "damage", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
public static final DataComponentType<Unit> UNBREAKABLE = register(id -> new DataComponentType<>(id, "unbreakable", unitReader(), unitWriter(), ObjectDataComponent::new));
public static final DataComponentType<UseEffects> USE_EFFECTS = register(id -> new DataComponentType<>(id, "use_effects", ItemTypes::readUseEffects, ItemTypes::writeUseEffects, ObjectDataComponent::new));
public static final DataComponentType<Component> CUSTOM_NAME = register(id -> new DataComponentType<>(id, "custom_name", MinecraftTypes::readComponent, MinecraftTypes::writeComponent, ObjectDataComponent::new));
public static final DataComponentType<Float> MINIMUM_ATTACK_CHARGE = register(id -> new DataComponentType<>(id, "minimum_attack_charge", ByteBuf::readFloat, ByteBuf::writeFloat, ObjectDataComponent::new));
public static final DataComponentType<Holder<Key>> DAMAGE_TYPE = register(id -> new DataComponentType<>(id, "damage_type", ItemTypes::readDamageType, ItemTypes::writeDamageType, ObjectDataComponent::new));
public static final DataComponentType<Component> ITEM_NAME = register(id -> new DataComponentType<>(id, "item_name", MinecraftTypes::readComponent, MinecraftTypes::writeComponent, ObjectDataComponent::new));
public static final DataComponentType<Key> ITEM_MODEL = register(id -> new DataComponentType<>(id, "item_model", MinecraftTypes::readResourceLocation, MinecraftTypes::writeResourceLocation, ObjectDataComponent::new));
public static final DataComponentType<List<Component>> LORE = register(id -> new DataComponentType<>(id, "lore", listReader(MinecraftTypes::readComponent), listWriter(MinecraftTypes::writeComponent), ObjectDataComponent::new));
Expand All @@ -53,13 +56,17 @@ public class DataComponentTypes {
public static final DataComponentType<Key> DAMAGE_RESISTANT = register(id -> new DataComponentType<>(id, "damage_resistant", MinecraftTypes::readResourceLocation, MinecraftTypes::writeResourceLocation, ObjectDataComponent::new));
public static final DataComponentType<ToolData> TOOL = register(id -> new DataComponentType<>(id, "tool", ItemTypes::readToolData, ItemTypes::writeToolData, ObjectDataComponent::new));
public static final DataComponentType<Weapon> WEAPON = register(id -> new DataComponentType<>(id, "weapon", ItemTypes::readWeapon, ItemTypes::writeWeapon, ObjectDataComponent::new));
public static final DataComponentType<AttackRange> ATTACK_RANGE = register(id -> new DataComponentType<>(id, "attack_range", ItemTypes::readAttackRange, ItemTypes::writeAttackRange, ObjectDataComponent::new));
public static final IntComponentType ENCHANTABLE = register(id -> new IntComponentType(id, "enchantable", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
public static final DataComponentType<Equippable> EQUIPPABLE = register(id -> new DataComponentType<>(id, "equippable", ItemTypes::readEquippable, ItemTypes::writeEquippable, ObjectDataComponent::new));
public static final DataComponentType<HolderSet> REPAIRABLE = register(id -> new DataComponentType<>(id, "repairable", MinecraftTypes::readHolderSet, MinecraftTypes::writeHolderSet, ObjectDataComponent::new));
public static final DataComponentType<Unit> GLIDER = register(id -> new DataComponentType<>(id, "glider", unitReader(), unitWriter(), ObjectDataComponent::new));
public static final DataComponentType<Key> TOOLTIP_STYLE = register(id -> new DataComponentType<>(id, "tooltip_style", MinecraftTypes::readResourceLocation, MinecraftTypes::writeResourceLocation, ObjectDataComponent::new));
public static final DataComponentType<List<ConsumeEffect>> DEATH_PROTECTION = register(id -> new DataComponentType<>(id, "death_protection", listReader(ItemTypes::readConsumeEffect), listWriter(ItemTypes::writeConsumeEffect), ObjectDataComponent::new));
public static final DataComponentType<BlocksAttacks> BLOCKS_ATTACKS = register(id -> new DataComponentType<>(id, "blocks_attacks", ItemTypes::readBlocksAttacks, ItemTypes::writeBlocksAttacks, ObjectDataComponent::new));
public static final DataComponentType<PiercingWeapon> PIERCING_WEAPON = register(id -> new DataComponentType<>(id, "piercing_weapon", ItemTypes::readPiercingWeapon, ItemTypes::writePiercingWeapon, ObjectDataComponent::new));
public static final DataComponentType<KineticWeapon> KINETIC_WEAPON = register(id -> new DataComponentType<>(id, "kinetic_weapon", ItemTypes::readKineticWeapon, ItemTypes::writeKineticWeapon, ObjectDataComponent::new));
public static final DataComponentType<SwingAnimation> SWING_ANIMATION = register(id -> new DataComponentType<>(id, "swing_animation", ItemTypes::readSwingAnimation, ItemTypes::writeSwingAnimation, ObjectDataComponent::new));
public static final DataComponentType<ItemEnchantments> STORED_ENCHANTMENTS = register(id -> new DataComponentType<>(id, "stored_enchantments", ItemTypes::readItemEnchantments, ItemTypes::writeItemEnchantments, ObjectDataComponent::new));
public static final IntComponentType DYED_COLOR = register(id -> new IntComponentType(id, "dyed_color", ByteBuf::readInt, ByteBuf::writeInt, IntDataComponent::new));
public static final IntComponentType MAP_COLOR = register(id -> new IntComponentType(id, "map_color", ByteBuf::readInt, ByteBuf::writeInt, IntDataComponent::new));
Expand Down Expand Up @@ -113,6 +120,7 @@ public class DataComponentTypes {
public static final IntComponentType PIG_VARIANT = register(id -> new IntComponentType(id, "pig/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
public static final IntComponentType COW_VARIANT = register(id -> new IntComponentType(id, "cow/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
public static final DataComponentType<Holder<Key>> CHICKEN_VARIANT = register(id -> new DataComponentType<>(id, "chicken/variant", MinecraftTypes::readChickenVariant, MinecraftTypes::writeChickenVariant, ObjectDataComponent::new));
public static final DataComponentType<Holder<Key>> ZOMBIE_NAUTILUS_VARIANT = register(id -> new DataComponentType<>(id, "zombie_nautilus/variant", MinecraftTypes::readZombieNautilusVariant, MinecraftTypes::writeZombieNautilusVariant, ObjectDataComponent::new));
public static final IntComponentType FROG_VARIANT = register(id -> new IntComponentType(id, "frog/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
public static final IntComponentType HORSE_VARIANT = register(id -> new IntComponentType(id, "horse/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new));
public static final DataComponentType<Holder<PaintingVariant>> PAINTING_VARIANT = register(id -> new DataComponentType<>(id, "painting/variant", MinecraftTypes::readPaintingVariant, MinecraftTypes::writePaintingVariant, ObjectDataComponent::new));
Expand Down
Loading