Skip to content

Commit

Permalink
More work on 1.21.50
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed Nov 21, 2024
1 parent b374a81 commit fd75c7f
Show file tree
Hide file tree
Showing 23 changed files with 253 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket;

import java.util.Collection;
import java.util.UUID;

import static java.util.Objects.requireNonNull;

Expand All @@ -30,7 +31,7 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacks
}

protected ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelper helper, boolean resource) {
String packId = helper.readString(buffer);
UUID packId = UUID.fromString(helper.readString(buffer));
String packVersion = helper.readString(buffer);
long packSize = buffer.readLongLE();
String contentKey = helper.readString(buffer);
Expand All @@ -42,7 +43,7 @@ protected ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHe
protected void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksInfoPacket.Entry entry, boolean resource) {
requireNonNull(entry, "ResourcePacketInfoPacket entry was null");

helper.writeString(buffer, entry.getPackId());
helper.writeString(buffer, entry.getPackId().toString());
helper.writeString(buffer, entry.getPackVersion());
buffer.writeLongLE(entry.getPackSize());
helper.writeString(buffer, entry.getContentKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.cloudburstmc.protocol.bedrock.codec.v291.serializer.ResourcePacksInfoSerializer_v291;
import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket;

import java.util.UUID;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ResourcePacksInfoSerializer_v332 extends ResourcePacksInfoSerializer_v291 {
public static final ResourcePacksInfoSerializer_v332 INSTANCE = new ResourcePacksInfoSerializer_v332();
Expand Down Expand Up @@ -37,7 +39,7 @@ public void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksI

@Override
public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelper helper, boolean resource) {
String packId = helper.readString(buffer);
UUID packId = UUID.fromString(helper.readString(buffer));
String packVersion = helper.readString(buffer);
long packSize = buffer.readLongLE();
String contentKey = helper.readString(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ protected ItemStackResponseSlot readItemEntry(ByteBuf buffer) {
buffer.readUnsignedByte(),
VarInts.readInt(buffer),
"",
0);
0,
"");
}

protected void writeItemEntry(ByteBuf buffer, ItemStackResponseSlot itemEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ protected ItemStackResponseSlot readItemEntry(ByteBuf buffer, BedrockCodecHelper
buffer.readUnsignedByte(),
VarInts.readInt(buffer),
"",
0);
0,
"");
}

protected void writeItemEntry(ByteBuf buffer, BedrockCodecHelper helper, ItemStackResponseSlot itemEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ protected ItemStackResponseSlot readItemEntry(ByteBuf buffer) {
buffer.readUnsignedByte(),
VarInts.readInt(buffer),
this.readString(buffer),
0);
0,
"");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.cloudburstmc.protocol.bedrock.codec.v332.serializer.ResourcePacksInfoSerializer_v332;
import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket;

import java.util.UUID;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ResourcePacksInfoSerializer_v422 extends ResourcePacksInfoSerializer_v332 {
public static final ResourcePacksInfoSerializer_v422 INSTANCE = new ResourcePacksInfoSerializer_v422();
Expand Down Expand Up @@ -37,7 +39,7 @@ public void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksI

@Override
public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelper helper, boolean resource) {
String packId = helper.readString(buffer);
UUID packId = UUID.fromString(helper.readString(buffer));
String packVersion = helper.readString(buffer);
long packSize = buffer.readLongLE();
String contentKey = helper.readString(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ protected ItemStackResponseSlot readItemEntry(ByteBuf buffer) {
buffer.readUnsignedByte(),
VarInts.readInt(buffer),
this.readString(buffer),
VarInts.readInt(buffer));
VarInts.readInt(buffer),
"");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) {

CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]);
OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean()));
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, null, null, listener, effects, null, null, null, null, null, null, null);
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, null, null, listener, effects, null, null, null, null, null, null, null, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) {

CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]);
OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean()));
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, null, null, null, null, null, null, null);
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, null, null, null, null, null, null, null, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket;

import java.util.Objects;
import java.util.UUID;

public class ResourcePacksInfoSerializer_v712 extends ResourcePacksInfoSerializer_v622 {
public static final ResourcePacksInfoSerializer_v712 INSTANCE = new ResourcePacksInfoSerializer_v712();
Expand All @@ -14,7 +15,7 @@ public class ResourcePacksInfoSerializer_v712 extends ResourcePacksInfoSerialize
public void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksInfoPacket.Entry entry, boolean resource) {
Objects.requireNonNull(entry, "ResourcePacketInfoPacket entry was null");

helper.writeString(buffer, entry.getPackId());
helper.writeString(buffer, entry.getPackId().toString());
helper.writeString(buffer, entry.getPackVersion());
buffer.writeLongLE(entry.getPackSize());
helper.writeString(buffer, entry.getContentKey());
Expand All @@ -29,7 +30,7 @@ public void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksI

@Override
public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelper helper, boolean resource) {
String packId = helper.readString(buffer);
UUID packId = UUID.fromString(helper.readString(buffer));
String packVersion = helper.readString(buffer);
long packSize = buffer.readLongLE();
String contentKey = helper.readString(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) {

CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]);
OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean()));
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, rotationSpeed, snapToTarget, entityOffset, null, null, null, null);
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, rotationSpeed, snapToTarget, entityOffset, null, null, null, null, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) {
CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]);
OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean()));
OptionalBoolean alignTargetAndCameraForward = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean()));
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, rotationSpeed, snapToTarget, entityOffset, horizontalRotationLimit, verticalRotationLimit, continueTargeting, alignTargetAndCameraForward);
return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, rotationSpeed, snapToTarget, entityOffset, horizontalRotationLimit, verticalRotationLimit, continueTargeting, alignTargetAndCameraForward, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.cloudburstmc.protocol.bedrock.codec.v729.serializer.ResourcePacksInfoSerializer_v729;
import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket;

import java.util.UUID;

@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public class ResourcePacksInfoSerializer_v748 extends ResourcePacksInfoSerializer_v729 {
public static final ResourcePacksInfoSerializer_v748 INSTANCE = new ResourcePacksInfoSerializer_v748();
Expand Down Expand Up @@ -35,7 +37,7 @@ public void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksI

@Override
public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelper helper, boolean resource) {
String packId = helper.readString(buffer);
UUID packId = UUID.fromString(helper.readString(buffer));
String packVersion = helper.readString(buffer);
long packSize = buffer.readLongLE();
String contentKey = helper.readString(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerSlotType;
import org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.TextProcessingEventOrigin;
import org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.action.ItemStackRequestActionType;
import org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.response.ItemStackResponseSlot;
import org.cloudburstmc.protocol.common.util.TypeMap;
import org.cloudburstmc.protocol.common.util.VarInts;

Expand All @@ -23,7 +24,7 @@ public BedrockCodecHelper_v765(EntityDataTypeMap entityData, TypeMap<Class<?>> g

@Override
public <T extends Enum<?>> void readLargeVarIntFlags(ByteBuf buffer, Set<T> flags, Class<T> clazz) {
BigInteger flagsInt = VarInts.readUnsignedBigVarInt(buffer);
BigInteger flagsInt = VarInts.readUnsignedBigVarInt(buffer, clazz.getEnumConstants().length);
for (T flag : clazz.getEnumConstants()) {
if (flagsInt.testBit(flag.ordinal())) {
flags.add(flag);
Expand All @@ -39,4 +40,29 @@ public <T extends Enum<?>> void writeLargeVarIntFlags(ByteBuf buffer, Set<T> fla
}
VarInts.writeUnsignedBigVarInt(buffer, flagsInt);
}

@Override
protected ItemStackResponseSlot readItemEntry(ByteBuf buffer) {
int slot = buffer.readUnsignedByte();
int hotbarSlot = buffer.readUnsignedByte();
int count = buffer.readUnsignedByte();
int stackNetworkId = VarInts.readInt(buffer);
String customName = this.readString(buffer);
String filteredCustomName = this.readString(buffer);
int durabilityCorrection = VarInts.readInt(buffer);
return new ItemStackResponseSlot(slot, hotbarSlot, count, stackNetworkId,
customName, durabilityCorrection, filteredCustomName);

}

@Override
protected void writeItemEntry(ByteBuf buffer, ItemStackResponseSlot itemEntry) {
buffer.writeByte(itemEntry.getSlot());
buffer.writeByte(itemEntry.getHotbarSlot());
buffer.writeByte(itemEntry.getCount());
VarInts.writeInt(buffer, itemEntry.getStackNetworkId());
this.writeString(buffer, itemEntry.getCustomName());
this.writeString(buffer, itemEntry.getFilteredCustomName());
VarInts.writeInt(buffer, itemEntry.getDurabilityCorrection());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@
import org.cloudburstmc.protocol.bedrock.codec.v332.serializer.LevelSoundEventSerializer_v332;
import org.cloudburstmc.protocol.bedrock.codec.v361.serializer.LevelEventGenericSerializer_v361;
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
import org.cloudburstmc.protocol.bedrock.codec.v765.serializer.CameraAimAssistPresetsSerializer_v765;
import org.cloudburstmc.protocol.bedrock.codec.v765.serializer.CameraAimAssistSerializer_v765;
import org.cloudburstmc.protocol.bedrock.codec.v765.serializer.PlayerAuthInputSerializer_v765;
import org.cloudburstmc.protocol.bedrock.codec.v765.serializer.ResourcePacksInfoSerializer_v765;
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
import org.cloudburstmc.protocol.bedrock.data.LevelEventType;
import org.cloudburstmc.protocol.bedrock.data.PacketRecipient;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.codec.v765.serializer.*;
import org.cloudburstmc.protocol.bedrock.data.*;
import org.cloudburstmc.protocol.bedrock.packet.*;
import org.cloudburstmc.protocol.common.util.TypeMap;

Expand All @@ -37,7 +31,15 @@ public class Bedrock_v765 extends Bedrock_v748 {
.insert(546, SoundEvent.UNDEFINED)
.build();

protected static final TypeMap<ParticleType> PARTICLE_TYPES = Bedrock_v748.PARTICLE_TYPES.toBuilder()
.insert(94, ParticleType.CREAKING_CRUMBLE)
.insert(95, ParticleType.PALE_OAK_LEAVES)
.insert(96, ParticleType.EYEBLOSSOM_OPEN)
.insert(97, ParticleType.EYEBLOSSOM_CLOSE)
.build();

protected static final TypeMap<LevelEventType> LEVEL_EVENTS = Bedrock_v748.LEVEL_EVENTS.toBuilder()
.insert(LEVEL_EVENT_PARTICLE_TYPE, PARTICLE_TYPES)
.insert(9816, LevelEvent.PARTICLE_CREAKING_HEART_TRIAL)
.build();

Expand All @@ -54,6 +56,7 @@ public class Bedrock_v765 extends Bedrock_v748 {
.updateSerializer(CameraAimAssistPacket.class, CameraAimAssistSerializer_v765.INSTANCE)
.updateSerializer(ResourcePacksInfoPacket.class, ResourcePacksInfoSerializer_v765.INSTANCE)
.updateSerializer(PlayerAuthInputPacket.class, PlayerAuthInputSerializer_v765.INSTANCE)
.updateSerializer(CameraPresetsPacket.class, CameraPresetsSerializer_v765.INSTANCE)
.registerPacket(CameraAimAssistPresetsPacket::new, CameraAimAssistPresetsSerializer_v765.INSTANCE, 320, PacketRecipient.CLIENT)
.build();
}
Loading

0 comments on commit fd75c7f

Please sign in to comment.