mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
24w21a
This commit is contained in:
parent
8965b5dc43
commit
019b09247f
12 changed files with 168 additions and 40 deletions
|
@ -7,11 +7,13 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.event.LevelEventType;
|
|||
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.BuiltinSound;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCookieRequestPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCustomReportDetailsPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundDisconnectPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundKeepAlivePacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundPingPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundResourcePackPopPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundResourcePackPushPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundServerLinksPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundStoreCookiePacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundTransferPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundUpdateTagsPacket;
|
||||
|
@ -223,9 +225,9 @@ public class MinecraftCodec {
|
|||
}
|
||||
|
||||
public static final PacketCodec CODEC = PacketCodec.builder()
|
||||
.protocolVersion((1 << 30) | 196)
|
||||
.protocolVersion((1 << 30) | 197)
|
||||
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
|
||||
.minecraftVersion("24w20a")
|
||||
.minecraftVersion("24w21a")
|
||||
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
|
||||
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
|
||||
)
|
||||
|
@ -262,6 +264,8 @@ public class MinecraftCodec {
|
|||
.registerClientboundPacket(ClientboundUpdateEnabledFeaturesPacket.class, ClientboundUpdateEnabledFeaturesPacket::new)
|
||||
.registerClientboundPacket(ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new)
|
||||
.registerClientboundPacket(ClientboundSelectKnownPacks.class, ClientboundSelectKnownPacks::new)
|
||||
.registerClientboundPacket(ClientboundCustomReportDetailsPacket.class, ClientboundCustomReportDetailsPacket::new)
|
||||
.registerClientboundPacket(ClientboundServerLinksPacket.class, ClientboundServerLinksPacket::new)
|
||||
.registerServerboundPacket(ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new)
|
||||
.registerServerboundPacket(ServerboundCookieResponsePacket.class, ServerboundCookieResponsePacket::new)
|
||||
.registerServerboundPacket(ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new)
|
||||
|
@ -393,6 +397,8 @@ public class MinecraftCodec {
|
|||
.registerClientboundPacket(ClientboundUpdateRecipesPacket.class, ClientboundUpdateRecipesPacket::new)
|
||||
.registerClientboundPacket(ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new)
|
||||
.registerClientboundPacket(ClientboundProjectilePowerPacket.class, ClientboundProjectilePowerPacket::new)
|
||||
.registerClientboundPacket(ClientboundCustomReportDetailsPacket.class, ClientboundCustomReportDetailsPacket::new)
|
||||
.registerClientboundPacket(ClientboundServerLinksPacket.class, ClientboundServerLinksPacket::new)
|
||||
.registerServerboundPacket(ServerboundAcceptTeleportationPacket.class, ServerboundAcceptTeleportationPacket::new)
|
||||
.registerServerboundPacket(ServerboundBlockEntityTagQueryPacket.class, ServerboundBlockEntityTagQueryPacket::new)
|
||||
.registerServerboundPacket(ServerboundChangeDifficultyPacket.class, ServerboundChangeDifficultyPacket::new)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.geysermc.mcprotocollib.protocol.data.game;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public record ServerLink(OptionalInt knownType, @Nullable Component unknownType, String url) {
|
||||
}
|
|
@ -7,15 +7,12 @@ import java.util.UUID;
|
|||
|
||||
@Data
|
||||
public class AttributeModifier {
|
||||
/**
|
||||
* Use {@link ModifierType} to determine built-in modifiers.
|
||||
*/
|
||||
private final @NonNull UUID uuid;
|
||||
private final @NonNull String id;
|
||||
private final double amount;
|
||||
private final @NonNull ModifierOperation operation;
|
||||
|
||||
public AttributeModifier(@NonNull UUID uuid, double amount, @NonNull ModifierOperation operation) {
|
||||
this.uuid = uuid;
|
||||
public AttributeModifier(@NonNull String id, double amount, @NonNull ModifierOperation operation) {
|
||||
this.id = id;
|
||||
this.amount = amount;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package org.geysermc.mcprotocollib.protocol.data.game.entity.attribute;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ModifierType { // TODO: out of date
|
||||
public static final UUID CREATURE_FLEE_SPEED_BONUS = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
|
||||
public static final UUID ENDERMAN_ATTACK_SPEED_BOOST = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
|
||||
public static final UUID SPRINT_SPEED_BOOST = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
|
||||
public static final UUID PIGZOMBIE_ATTACK_SPEED_BOOST = UUID.fromString("49455A49-7EC5-45BA-B886-3B90B23A1718");
|
||||
public static final UUID WITCH_DRINKING_SPEED_PENALTY = UUID.fromString("5CD17E52-A79A-43D3-A529-90FDE04B181E");
|
||||
public static final UUID ZOMBIE_BABY_SPEED_BOOST = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
|
||||
public static final UUID ATTACK_DAMAGE_MODIFIER = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
|
||||
public static final UUID ATTACK_SPEED_MODIFIER = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3");
|
||||
public static final UUID SPEED_POTION_MODIFIER = UUID.fromString("91AEAA56-376B-4498-935B-2F7F68070635");
|
||||
public static final UUID HEALTH_BOOST_POTION_MODIFIER = UUID.fromString("5D6F0BA2-1186-46AC-B896-C61C5CEE99CC");
|
||||
public static final UUID SLOW_POTION_MODIFIER = UUID.fromString("7107DE5E-7CE8-4030-940E-514C1F160890");
|
||||
public static final UUID STRENGTH_POTION_MODIFIER = UUID.fromString("648D7064-6A60-4F59-8ABE-C2C23A6DD7A9");
|
||||
public static final UUID WEAKNESS_POTION_MODIFIER = UUID.fromString("22653B89-116E-49DC-9B6B-9971489B5BE5");
|
||||
public static final UUID HASTE_POTION_MODIFIER = UUID.fromString("AF8B6E3F-3328-4C0A-AA36-5BA2BB9DBEF3");
|
||||
public static final UUID MINING_FATIGUE_POTION_MODIFIER = UUID.fromString("55FCED67-E92A-486E-9800-B47F202C4386");
|
||||
public static final UUID LUCK_POTION_MODIFIER = UUID.fromString("03C3C89D-7037-4B42-869F-B146BCB64D2E");
|
||||
public static final UUID UNLUCK_POTION_MODIFIER = UUID.fromString("CC5AF142-2BD2-4215-B636-2605AED11727");
|
||||
public static final UUID BOOTS_MODIFIER = UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B");
|
||||
public static final UUID LEGGINGS_MODIFIER = UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D");
|
||||
public static final UUID CHESTPLATE_MODIFIER = UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E");
|
||||
public static final UUID HELMET_MODIFIER = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150");
|
||||
public static final UUID BODY_MODIFIER = UUID.fromString("C1C72771-8B8E-BA4A-ACE0-81A93C8928B2");
|
||||
public static final UUID COVERED_ARMOR_BONUS = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
|
||||
}
|
|
@ -62,6 +62,7 @@ public class DataComponentType<T> {
|
|||
public static final DataComponentType<NbtMap> BLOCK_ENTITY_DATA = new DataComponentType<>(ItemCodecHelper::readCompoundTag, ItemCodecHelper::writeAnyTag, ObjectDataComponent::new);
|
||||
public static final DataComponentType<Holder<Instrument>> INSTRUMENT = new DataComponentType<>(ItemCodecHelper::readInstrument, ItemCodecHelper::writeInstrument, ObjectDataComponent::new);
|
||||
public static final IntComponentType OMINOUS_BOTTLE_AMPLIFIER = new IntComponentType(ItemCodecHelper::readVarInt, ItemCodecHelper::writeVarInt, IntDataComponent::new);
|
||||
public static final DataComponentType<JukeboxPlayable> JUKEBOX_PLAYABLE = new DataComponentType<>(ItemCodecHelper::readJukeboxPlayable, ItemCodecHelper::writeJukeboxPlayable, ObjectDataComponent::new);
|
||||
public static final DataComponentType<NbtList<?>> RECIPES = new DataComponentType<>(ItemCodecHelper::readRecipes, ItemCodecHelper::writeRecipes, ObjectDataComponent::new);
|
||||
public static final DataComponentType<LodestoneTracker> LODESTONE_TRACKER = new DataComponentType<>(ItemCodecHelper::readLodestoneTarget, ItemCodecHelper::writeLodestoneTarget, ObjectDataComponent::new);
|
||||
public static final DataComponentType<Fireworks.FireworkExplosion> FIREWORK_EXPLOSION = new DataComponentType<>(ItemCodecHelper::readFireworkExplosion, ItemCodecHelper::writeFireworkExplosion, ObjectDataComponent::new);
|
||||
|
|
|
@ -474,6 +474,48 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
|
|||
this.writeAnyTag(buf, recipes);
|
||||
}
|
||||
|
||||
public JukeboxPlayable readJukeboxPlayable(ByteBuf buf) {
|
||||
Holder<JukeboxPlayable.JukeboxSong> songHolder = null;
|
||||
String songLocation = null;
|
||||
if (buf.readBoolean()) {
|
||||
songHolder = this.readHolder(buf, this::readJukeboxSong);
|
||||
} else {
|
||||
songLocation = this.readResourceLocation(buf);
|
||||
}
|
||||
boolean showInTooltip = buf.readBoolean();
|
||||
return new JukeboxPlayable(songHolder, songLocation, showInTooltip);
|
||||
}
|
||||
|
||||
public void writeJukeboxPlayable(ByteBuf buf, JukeboxPlayable playable) {
|
||||
buf.writeBoolean(playable.songHolder() != null);
|
||||
if (playable.songHolder() != null) {
|
||||
this.writeHolder(buf, playable.songHolder(), this::writeJukeboxSong);
|
||||
} else {
|
||||
this.writeResourceLocation(buf, playable.songLocation());
|
||||
}
|
||||
buf.writeBoolean(playable.showInTooltip());
|
||||
}
|
||||
|
||||
public JukeboxPlayable.JukeboxSong readJukeboxSong(ByteBuf buf) {
|
||||
Sound soundEvent = this.readById(buf, BuiltinSound::from, this::readSoundEvent);
|
||||
Component description = this.readComponent(buf);
|
||||
float lengthInSeconds = buf.readFloat();
|
||||
int comparatorOutput = this.readVarInt(buf);
|
||||
return new JukeboxPlayable.JukeboxSong(soundEvent, description, lengthInSeconds, comparatorOutput);
|
||||
}
|
||||
|
||||
public void writeJukeboxSong(ByteBuf buf, JukeboxPlayable.JukeboxSong song) {
|
||||
if (song.soundEvent() instanceof CustomSound) {
|
||||
this.writeVarInt(buf, 0);
|
||||
this.writeSoundEvent(buf, song.soundEvent());
|
||||
} else {
|
||||
this.writeVarInt(buf, ((BuiltinSound) song.soundEvent()).ordinal() + 1);
|
||||
}
|
||||
this.writeComponent(buf, song.description());
|
||||
buf.writeFloat(song.lengthInSeconds());
|
||||
this.writeVarInt(buf, song.comparatorOutput());
|
||||
}
|
||||
|
||||
public LodestoneTracker readLodestoneTarget(ByteBuf buf) {
|
||||
return new LodestoneTracker(this.readNullable(buf, this::readGlobalPos), buf.readBoolean());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public record JukeboxPlayable(@Nullable Holder<JukeboxSong> songHolder, @Nullable String songLocation, boolean showInTooltip) {
|
||||
public record JukeboxSong(Sound soundEvent, Component description, float lengthInSeconds, int comparatorOutput) {
|
||||
}
|
||||
}
|
|
@ -1449,6 +1449,7 @@ public enum BuiltinSound implements Sound {
|
|||
BLOCK_VAULT_CLOSE_SHUTTER("block.vault.close_shutter"),
|
||||
BLOCK_VAULT_DEACTIVATE("block.vault.deactivate"),
|
||||
BLOCK_VAULT_EJECT_ITEM("block.vault.eject_item"),
|
||||
BLOCK_VAULT_REJECT_REWARDED_PLAYER("block.vault.reject_rewarded_player"),
|
||||
BLOCK_VAULT_FALL("block.vault.fall"),
|
||||
BLOCK_VAULT_HIT("block.vault.hit"),
|
||||
BLOCK_VAULT_INSERT_ITEM("block.vault.insert_item"),
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package org.geysermc.mcprotocollib.protocol.packet.common.clientbound;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.With;
|
||||
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
|
||||
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@With
|
||||
@AllArgsConstructor
|
||||
public class ClientboundCustomReportDetailsPacket implements MinecraftPacket {
|
||||
private final Map<String, String> details;
|
||||
|
||||
public ClientboundCustomReportDetailsPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||
this.details = new HashMap<>();
|
||||
|
||||
int count = helper.readVarInt(in);
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.details.put(helper.readString(in, 128), helper.readString(in, 4096));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||
helper.writeVarInt(out, this.details.size());
|
||||
for (Map.Entry<String, String> entry : this.details.entrySet()) {
|
||||
helper.writeString(out, entry.getKey());
|
||||
helper.writeString(out, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.geysermc.mcprotocollib.protocol.packet.common.clientbound;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.With;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
|
||||
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.ServerLink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@Data
|
||||
@With
|
||||
@AllArgsConstructor
|
||||
public class ClientboundServerLinksPacket implements MinecraftPacket {
|
||||
private final List<ServerLink> links;
|
||||
|
||||
public ClientboundServerLinksPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||
this.links = new ArrayList<>();
|
||||
|
||||
int length = helper.readVarInt(in);
|
||||
for (int i = 0; i < length; i++) {
|
||||
OptionalInt knownType = OptionalInt.empty();
|
||||
Component unknownType = null;
|
||||
if (in.readBoolean()) {
|
||||
knownType = OptionalInt.of(helper.readVarInt(in));
|
||||
} else {
|
||||
unknownType = helper.readComponent(in);
|
||||
}
|
||||
|
||||
String url = helper.readString(in);
|
||||
this.links.add(new ServerLink(knownType, unknownType, url));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||
helper.writeVarInt(out, this.links.size());
|
||||
for (ServerLink link : this.links) {
|
||||
out.writeBoolean(link.knownType().isPresent());
|
||||
if (link.knownType().isPresent()) {
|
||||
helper.writeVarInt(out, link.knownType().getAsInt());
|
||||
} else {
|
||||
helper.writeComponent(out, link.unknownType());
|
||||
}
|
||||
|
||||
helper.writeString(out, link.url());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,10 +31,10 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket {
|
|||
List<AttributeModifier> modifiers = new ArrayList<>();
|
||||
int len = helper.readVarInt(in);
|
||||
for (int ind = 0; ind < len; ind++) {
|
||||
modifiers.add(new AttributeModifier(helper.readUUID(in), in.readDouble(), helper.readModifierOperation(in)));
|
||||
modifiers.add(new AttributeModifier(helper.readResourceLocation(in), in.readDouble(), helper.readModifierOperation(in)));
|
||||
}
|
||||
|
||||
AttributeType type = AttributeType.Builtin.BUILTIN.get(attributeId); //.computeIfAbsent(attributeId, AttributeType.Custom::new); TODO
|
||||
AttributeType type = AttributeType.Builtin.BUILTIN.get(attributeId);
|
||||
this.attributes.add(new Attribute(type, value, modifiers));
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket {
|
|||
out.writeDouble(attribute.getValue());
|
||||
helper.writeVarInt(out, attribute.getModifiers().size());
|
||||
for (AttributeModifier modifier : attribute.getModifiers()) {
|
||||
helper.writeUUID(out, modifier.getUuid());
|
||||
helper.writeResourceLocation(out, modifier.getId());
|
||||
out.writeDouble(modifier.getAmount());
|
||||
helper.writeModifierOperation(out, modifier.getOperation());
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue