mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-27 16:12:23 -05:00
24w37a
This commit is contained in:
parent
7f7445f6f0
commit
25103382a3
6 changed files with 20 additions and 13 deletions
|
@ -210,9 +210,9 @@ import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.Serverbound
|
|||
|
||||
public class MinecraftCodec {
|
||||
public static final PacketCodec CODEC = PacketCodec.builder()
|
||||
.protocolVersion((1 << 30) | 208)
|
||||
.protocolVersion((1 << 30) | 209)
|
||||
.helper(MinecraftCodecHelper::new)
|
||||
.minecraftVersion("24w36a")
|
||||
.minecraftVersion("24w37a")
|
||||
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
|
||||
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
|
||||
)
|
||||
|
|
|
@ -46,13 +46,14 @@ public class DataComponentType<T> {
|
|||
public static final DataComponentType<Consumable> CONSUMABLE = new DataComponentType<>(ItemCodecHelper::readConsumable, ItemCodecHelper::writeConsumable, ObjectDataComponent::new);
|
||||
public static final DataComponentType<ItemStack> USE_REMAINDER = new DataComponentType<>(ItemCodecHelper::readItemStack, ItemCodecHelper::writeItemStack, ObjectDataComponent::new);
|
||||
public static final DataComponentType<UseCooldown> USE_COOLDOWN = new DataComponentType<>(ItemCodecHelper::readUseCooldown, ItemCodecHelper::writeUseCooldown, ObjectDataComponent::new);
|
||||
public static final DataComponentType<Unit> FIRE_RESISTANT = new DataComponentType<>(unitReader(), unitWriter(), ObjectDataComponent::new);
|
||||
public static final DataComponentType<Key> DAMAGE_RESISTANT = new DataComponentType<>(ItemCodecHelper::readResourceLocation, ItemCodecHelper::writeResourceLocation, ObjectDataComponent::new);
|
||||
public static final DataComponentType<ToolData> TOOL = new DataComponentType<>(ItemCodecHelper::readToolData, ItemCodecHelper::writeToolData, ObjectDataComponent::new);
|
||||
public static final IntComponentType ENCHANTABLE = new IntComponentType(ItemCodecHelper::readVarInt, ItemCodecHelper::writeVarInt, IntDataComponent::new);
|
||||
public static final DataComponentType<Equippable> EQUIPPABLE = new DataComponentType<>(ItemCodecHelper::readEquippable, ItemCodecHelper::writeEquippable, ObjectDataComponent::new);
|
||||
public static final DataComponentType<HolderSet> REPAIRABLE = new DataComponentType<>(ItemCodecHelper::readHolderSet, ItemCodecHelper::writeHolderSet, ObjectDataComponent::new);
|
||||
public static final DataComponentType<Unit> GLIDER = new DataComponentType<>(unitReader(), unitWriter(), ObjectDataComponent::new);
|
||||
public static final DataComponentType<Key> TOOLTIP_STYLE = new DataComponentType<>(ItemCodecHelper::readResourceLocation, ItemCodecHelper::writeResourceLocation, ObjectDataComponent::new);
|
||||
public static final DataComponentType<List<ConsumeEffect>> DEATH_PROTECTION = new DataComponentType<>(listReader(ItemCodecHelper::readConsumeEffect), listWriter(ItemCodecHelper::writeConsumeEffect), ObjectDataComponent::new);
|
||||
public static final DataComponentType<ItemEnchantments> STORED_ENCHANTMENTS = new DataComponentType<>(ItemCodecHelper::readItemEnchantments, ItemCodecHelper::writeItemEnchantments, ObjectDataComponent::new);
|
||||
public static final DataComponentType<DyedItemColor> DYED_COLOR = new DataComponentType<>(ItemCodecHelper::readDyedItemColor, ItemCodecHelper::writeDyedItemColor, ObjectDataComponent::new);
|
||||
public static final IntComponentType MAP_COLOR = new IntComponentType((helper, input) -> input.readInt(), (helper, output, value) -> output.writeInt(value), IntDataComponent::new);
|
||||
|
|
|
@ -5,5 +5,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||
import org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;
|
||||
|
||||
public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable HolderSet allowedEntities, boolean dispensable) {
|
||||
public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable HolderSet allowedEntities,
|
||||
boolean dispensable, boolean swappable, boolean damageOnHurt) {
|
||||
}
|
||||
|
|
|
@ -172,7 +172,9 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
|
|||
Key model = this.readNullable(buf, this::readResourceLocation);
|
||||
HolderSet allowedEntities = this.readNullable(buf, this::readHolderSet);
|
||||
boolean dispensable = buf.readBoolean();
|
||||
return new Equippable(slot, equipSound, model, allowedEntities, dispensable);
|
||||
boolean swappable = buf.readBoolean();
|
||||
boolean damageOnHurt = buf.readBoolean();
|
||||
return new Equippable(slot, equipSound, model, allowedEntities, dispensable, swappable, damageOnHurt);
|
||||
}
|
||||
|
||||
public void writeEquippable(ByteBuf buf, Equippable equippable) {
|
||||
|
@ -187,6 +189,8 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
|
|||
this.writeNullable(buf, equippable.model(), this::writeResourceLocation);
|
||||
this.writeNullable(buf, equippable.allowedEntities(), this::writeHolderSet);
|
||||
buf.writeBoolean(equippable.dispensable());
|
||||
buf.writeBoolean(equippable.swappable());
|
||||
buf.writeBoolean(equippable.damageOnHurt());
|
||||
}
|
||||
|
||||
public ItemAttributeModifiers readItemAttributeModifiers(ByteBuf buf) {
|
||||
|
@ -231,7 +235,8 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
|
|||
int customColor = buf.readBoolean() ? buf.readInt() : -1;
|
||||
|
||||
List<MobEffectInstance> customEffects = this.readList(buf, this::readEffectInstance);
|
||||
return new PotionContents(potionId, customColor, customEffects);
|
||||
String customName = this.readNullable(buf, this::readString);
|
||||
return new PotionContents(potionId, customColor, customEffects, customName);
|
||||
}
|
||||
|
||||
public void writePotionContents(ByteBuf buf, PotionContents contents) {
|
||||
|
@ -250,6 +255,7 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
|
|||
}
|
||||
|
||||
this.writeList(buf, contents.getCustomEffects(), this::writeEffectInstance);
|
||||
this.writeNullable(buf, contents.getCustomName(), this::writeString);
|
||||
}
|
||||
|
||||
public FoodProperties readFoodProperties(ByteBuf buf) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.geysermc.mcprotocollib.protocol.data.game.item.component;
|
|||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -11,4 +12,5 @@ public class PotionContents {
|
|||
private final int potionId;
|
||||
private final int customColor;
|
||||
private final List<MobEffectInstance> customEffects;
|
||||
private final @Nullable String customName;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket {
|
|||
this.id = helper.readVarInt(in);
|
||||
this.position = Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble());
|
||||
this.deltaMovement = Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble());
|
||||
this.yRot = in.readByte() * 360 / 256F;
|
||||
this.xRot = in.readByte() * 360 / 256F;
|
||||
this.yRot = in.readFloat();
|
||||
this.xRot = in.readFloat();
|
||||
|
||||
this.relativeArguments = new ArrayList<>();
|
||||
int flags = in.readInt();
|
||||
|
@ -56,11 +56,8 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket {
|
|||
out.writeDouble(this.deltaMovement.getX());
|
||||
out.writeDouble(this.deltaMovement.getY());
|
||||
out.writeDouble(this.deltaMovement.getZ());
|
||||
|
||||
float yRot = this.yRot * 256F / 360F;
|
||||
out.writeByte(yRot < (int)yRot ? (int)yRot - 1 : (int)yRot);
|
||||
float xRot = this.xRot * 256F / 360F;
|
||||
out.writeByte(xRot < (int)xRot ? (int)xRot - 1 : (int)xRot);
|
||||
out.writeFloat(this.yRot);
|
||||
out.writeFloat(this.xRot);
|
||||
|
||||
int flags = 0;
|
||||
for (PositionElement element : this.relativeArguments) {
|
||||
|
|
Loading…
Reference in a new issue