-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
594 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...c/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v765/BedrockCodecHelper_v765.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.cloudburstmc.protocol.bedrock.codec.v765; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import org.cloudburstmc.protocol.bedrock.codec.EntityDataTypeMap; | ||
import org.cloudburstmc.protocol.bedrock.codec.v729.BedrockCodecHelper_v729; | ||
import org.cloudburstmc.protocol.bedrock.data.Ability; | ||
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.common.util.TypeMap; | ||
import org.cloudburstmc.protocol.common.util.VarInts; | ||
|
||
import java.math.BigInteger; | ||
import java.util.Set; | ||
import java.util.concurrent.ThreadLocalRandom; | ||
|
||
public class BedrockCodecHelper_v765 extends BedrockCodecHelper_v729 { | ||
|
||
public BedrockCodecHelper_v765(EntityDataTypeMap entityData, TypeMap<Class<?>> gameRulesTypes, TypeMap<ItemStackRequestActionType> stackRequestActionTypes, | ||
TypeMap<ContainerSlotType> containerSlotTypes, TypeMap<Ability> abilities, TypeMap<TextProcessingEventOrigin> textProcessingEventOrigins) { | ||
super(entityData, gameRulesTypes, stackRequestActionTypes, containerSlotTypes, abilities, textProcessingEventOrigins); | ||
} | ||
|
||
@Override | ||
public <T extends Enum<?>> void readLargeVarIntFlags(ByteBuf buffer, Set<T> flags, Class<T> clazz) { | ||
BigInteger flagsInt = VarInts.readUnsignedBigVarInt(buffer); | ||
for (T flag : clazz.getEnumConstants()) { | ||
if (flagsInt.testBit(flag.ordinal())) { | ||
flags.add(flag); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public <T extends Enum<?>> void writeLargeVarIntFlags(ByteBuf buffer, Set<T> flags, Class<T> clazz) { | ||
BigInteger flagsInt = new BigInteger(clazz.getEnumConstants().length, ThreadLocalRandom.current()); | ||
for (T flag : flags) { | ||
flagsInt = flagsInt.setBit(flag.ordinal()); | ||
} | ||
VarInts.writeUnsignedBigVarInt(buffer, flagsInt); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v765/Bedrock_v765.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.cloudburstmc.protocol.bedrock.codec.v765; | ||
|
||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; | ||
import org.cloudburstmc.protocol.bedrock.codec.v291.serializer.LevelEventSerializer_v291; | ||
import org.cloudburstmc.protocol.bedrock.codec.v291.serializer.LevelSoundEvent1Serializer_v291; | ||
import org.cloudburstmc.protocol.bedrock.codec.v313.serializer.LevelSoundEvent2Serializer_v313; | ||
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.packet.*; | ||
import org.cloudburstmc.protocol.common.util.TypeMap; | ||
|
||
public class Bedrock_v765 extends Bedrock_v748 { | ||
|
||
protected static final TypeMap<SoundEvent> SOUND_EVENTS = Bedrock_v748.SOUND_EVENTS | ||
.toBuilder() | ||
.insert(532, SoundEvent.IMITATE_CREAKING) | ||
.replace(534, SoundEvent.SPONGE_ABSORB) | ||
.insert(536, SoundEvent.BLOCK_CREAKING_HEART_TRAIL) | ||
.insert(537, SoundEvent.CREAKING_HEART_SPAWN) | ||
.insert(538, SoundEvent.ACTIVATE) | ||
.insert(539, SoundEvent.DEACTIVATE) | ||
.insert(540, SoundEvent.FREEZE) | ||
.insert(541, SoundEvent.UNFREEZE) | ||
.insert(542, SoundEvent.OPEN) | ||
.insert(543, SoundEvent.OPEN_LONG) | ||
.insert(544, SoundEvent.CLOSE) | ||
.insert(545, SoundEvent.CLOSE_LONG) | ||
.insert(546, SoundEvent.UNDEFINED) | ||
.build(); | ||
|
||
protected static final TypeMap<LevelEventType> LEVEL_EVENTS = Bedrock_v748.LEVEL_EVENTS.toBuilder() | ||
.insert(9816, LevelEvent.PARTICLE_CREAKING_HEART_TRIAL) | ||
.build(); | ||
|
||
public static final BedrockCodec CODEC = Bedrock_v748.CODEC.toBuilder() | ||
.raknetProtocolVersion(11) | ||
.protocolVersion(765) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Alemiz112
Author
Member
|
||
.minecraftVersion("1.21.50") | ||
.helper(() -> new BedrockCodecHelper_v765(ENTITY_DATA, GAME_RULE_TYPES, ITEM_STACK_REQUEST_TYPES, CONTAINER_SLOT_TYPES, PLAYER_ABILITIES, TEXT_PROCESSING_ORIGINS)) | ||
.updateSerializer(LevelEventPacket.class, new LevelEventSerializer_v291(LEVEL_EVENTS)) | ||
.updateSerializer(LevelEventGenericPacket.class, new LevelEventGenericSerializer_v361(LEVEL_EVENTS)) | ||
.updateSerializer(LevelSoundEvent1Packet.class, new LevelSoundEvent1Serializer_v291(SOUND_EVENTS)) | ||
.updateSerializer(LevelSoundEvent2Packet.class, new LevelSoundEvent2Serializer_v313(SOUND_EVENTS)) | ||
.updateSerializer(LevelSoundEventPacket.class, new LevelSoundEventSerializer_v332(SOUND_EVENTS)) | ||
.updateSerializer(CameraAimAssistPacket.class, CameraAimAssistSerializer_v765.INSTANCE) | ||
.updateSerializer(ResourcePacksInfoPacket.class, ResourcePacksInfoSerializer_v765.INSTANCE) | ||
.updateSerializer(PlayerAuthInputPacket.class, PlayerAuthInputSerializer_v765.INSTANCE) | ||
.registerPacket(CameraAimAssistPresetsPacket::new, CameraAimAssistPresetsSerializer_v765.INSTANCE, 320, PacketRecipient.CLIENT) | ||
.build(); | ||
} |
97 changes: 97 additions & 0 deletions
97
...burstmc/protocol/bedrock/codec/v765/serializer/CameraAimAssistPresetsSerializer_v765.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package org.cloudburstmc.protocol.bedrock.codec.v765.serializer; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; | ||
import org.cloudburstmc.protocol.bedrock.codec.BedrockPacketSerializer; | ||
import org.cloudburstmc.protocol.bedrock.data.camera.*; | ||
import org.cloudburstmc.protocol.bedrock.packet.CameraAimAssistPresetsPacket; | ||
|
||
public class CameraAimAssistPresetsSerializer_v765 implements BedrockPacketSerializer<CameraAimAssistPresetsPacket> { | ||
public static final CameraAimAssistPresetsSerializer_v765 INSTANCE = new CameraAimAssistPresetsSerializer_v765(); | ||
|
||
@Override | ||
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistPresetsPacket packet) { | ||
helper.writeArray(buffer, packet.getCategories(), this::writeCategories); | ||
helper.writeArray(buffer, packet.getPresets(), this::writePreset); | ||
} | ||
|
||
@Override | ||
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistPresetsPacket packet) { | ||
helper.readArray(buffer, packet.getCategories(), this::readCategories); | ||
helper.readArray(buffer, packet.getPresets(), this::readPreset); | ||
} | ||
|
||
protected void writeCategories(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistCategories categories) { | ||
helper.writeString(buffer, categories.getIdentifier()); | ||
helper.writeArray(buffer, categories.getCategories(), this::writeCategory); | ||
} | ||
|
||
protected CameraAimAssistCategories readCategories(ByteBuf buffer, BedrockCodecHelper helper) { | ||
final CameraAimAssistCategories categories = new CameraAimAssistCategories(); | ||
categories.setIdentifier(helper.readString(buffer)); | ||
helper.readArray(buffer, categories.getCategories(), this::readCategory); | ||
return categories; | ||
} | ||
|
||
protected void writeCategory(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistCategory category) { | ||
helper.writeString(buffer, category.getName()); | ||
|
||
helper.writeArray(buffer, category.getEntityPriorities(), this::writePriority); | ||
helper.writeArray(buffer, category.getBlockPriorities(), this::writePriority); | ||
|
||
helper.writeOptionalNull(buffer, category.getEntityDefaultPriorities(), ByteBuf::writeIntLE); | ||
helper.writeOptionalNull(buffer, category.getBlockDefaultPriorities(), ByteBuf::writeIntLE); | ||
} | ||
|
||
protected CameraAimAssistCategory readCategory(ByteBuf buffer, BedrockCodecHelper helper) { | ||
CameraAimAssistCategory category = new CameraAimAssistCategory(); | ||
category.setName(helper.readString(buffer)); | ||
|
||
helper.readArray(buffer, category.getEntityPriorities(), this::readPriority); | ||
helper.readArray(buffer, category.getBlockPriorities(), this::readPriority); | ||
|
||
category.setEntityDefaultPriorities(helper.readOptional(buffer, null, ByteBuf::readIntLE)); | ||
category.setBlockDefaultPriorities(helper.readOptional(buffer, null, ByteBuf::readIntLE)); | ||
return category; | ||
} | ||
|
||
protected void writePreset(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistPresetDefinition preset) { | ||
helper.writeString(buffer, preset.getIdentifier()); | ||
helper.writeString(buffer, preset.getCategories()); | ||
helper.writeArray(buffer, preset.getExclusionList(), helper::writeString); | ||
helper.writeArray(buffer, preset.getLiquidTargetingList(), helper::writeString); | ||
helper.writeArray(buffer, preset.getItemSettings(), this::writeItemSetting); | ||
helper.writeOptionalNull(buffer, preset.getDefaultItemSettings(), helper::writeString); | ||
helper.writeOptionalNull(buffer, preset.getHandSettings(), helper::writeString); | ||
} | ||
|
||
protected CameraAimAssistPresetDefinition readPreset(ByteBuf buffer, BedrockCodecHelper helper) { | ||
final CameraAimAssistPresetDefinition preset = new CameraAimAssistPresetDefinition(); | ||
preset.setIdentifier(helper.readString(buffer)); | ||
preset.setCategories(helper.readString(buffer)); | ||
helper.readArray(buffer, preset.getExclusionList(), helper::readString); | ||
helper.readArray(buffer, preset.getLiquidTargetingList(), helper::readString); | ||
helper.readArray(buffer, preset.getItemSettings(), this::readItemSetting); | ||
preset.setDefaultItemSettings(helper.readOptional(buffer, null, helper::readString)); | ||
preset.setHandSettings(helper.readOptional(buffer, null, helper::readString)); | ||
return preset; | ||
} | ||
|
||
private void writePriority(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistPriority priority) { | ||
helper.writeString(buffer, priority.getName()); | ||
buffer.writeIntLE(priority.getPriority()); | ||
} | ||
|
||
private CameraAimAssistPriority readPriority(ByteBuf buffer, BedrockCodecHelper helper) { | ||
return new CameraAimAssistPriority(helper.readString(buffer), buffer.readIntLE()); | ||
} | ||
|
||
private void writeItemSetting(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistItemSettings settings) { | ||
helper.writeString(buffer, settings.getItemId()); | ||
helper.writeString(buffer, settings.getCategory()); | ||
} | ||
|
||
private CameraAimAssistItemSettings readItemSetting(ByteBuf buffer, BedrockCodecHelper helper) { | ||
return new CameraAimAssistItemSettings(helper.readString(buffer), helper.readString(buffer)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...g/cloudburstmc/protocol/bedrock/codec/v765/serializer/CameraAimAssistSerializer_v765.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.cloudburstmc.protocol.bedrock.codec.v765.serializer; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; | ||
import org.cloudburstmc.protocol.bedrock.codec.v729.serializer.CameraAimAssistSerializer_v729; | ||
import org.cloudburstmc.protocol.bedrock.packet.CameraAimAssistPacket; | ||
|
||
public class CameraAimAssistSerializer_v765 extends CameraAimAssistSerializer_v729 { | ||
public static final CameraAimAssistSerializer_v765 INSTANCE = new CameraAimAssistSerializer_v765(); | ||
|
||
@Override | ||
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistPacket packet) { | ||
helper.writeString(buffer, packet.getPresetId()); | ||
super.serialize(buffer, helper, packet); | ||
} | ||
|
||
@Override | ||
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, CameraAimAssistPacket packet) { | ||
packet.setPresetId(helper.readString(buffer)); | ||
super.deserialize(buffer, helper, packet); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...g/cloudburstmc/protocol/bedrock/codec/v765/serializer/PlayerAuthInputSerializer_v765.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package org.cloudburstmc.protocol.bedrock.codec.v765.serializer; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import org.cloudburstmc.math.vector.Vector2f; | ||
import org.cloudburstmc.math.vector.Vector3f; | ||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; | ||
import org.cloudburstmc.protocol.bedrock.codec.v748.serializer.PlayerAuthInputSerializer_v748; | ||
import org.cloudburstmc.protocol.bedrock.data.PlayerAuthInputData; | ||
import org.cloudburstmc.protocol.bedrock.data.PlayerBlockActionData; | ||
import org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket; | ||
import org.cloudburstmc.protocol.common.util.VarInts; | ||
|
||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PlayerAuthInputSerializer_v765 extends PlayerAuthInputSerializer_v748 { | ||
|
||
public static final PlayerAuthInputSerializer_v765 INSTANCE = new PlayerAuthInputSerializer_v765(); | ||
|
||
@Override | ||
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, PlayerAuthInputPacket packet) { | ||
Vector3f rotation = packet.getRotation(); | ||
buffer.writeFloatLE(rotation.getX()); | ||
buffer.writeFloatLE(rotation.getY()); | ||
helper.writeVector3f(buffer, packet.getPosition()); | ||
buffer.writeFloatLE(packet.getMotion().getX()); | ||
buffer.writeFloatLE(packet.getMotion().getY()); | ||
buffer.writeFloatLE(rotation.getZ()); | ||
helper.writeLargeVarIntFlags(buffer, packet.getInputData(), PlayerAuthInputData.class); | ||
VarInts.writeUnsignedInt(buffer, packet.getInputMode().ordinal()); | ||
VarInts.writeUnsignedInt(buffer, packet.getPlayMode().ordinal()); | ||
writeInteractionModel(buffer, helper, packet); | ||
helper.writeVector2f(buffer, packet.getInteractRotation()); | ||
VarInts.writeUnsignedLong(buffer, packet.getTick()); | ||
helper.writeVector3f(buffer, packet.getDelta()); | ||
if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_INTERACTION)) { | ||
this.writeItemUseTransaction(buffer, helper, packet.getItemUseTransaction()); | ||
} | ||
if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_STACK_REQUEST)) { | ||
helper.writeItemStackRequest(buffer, packet.getItemStackRequest()); | ||
} | ||
if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_BLOCK_ACTIONS)) { | ||
VarInts.writeInt(buffer, packet.getPlayerActions().size()); | ||
for (PlayerBlockActionData actionData : packet.getPlayerActions()) { | ||
writePlayerBlockActionData(buffer, helper, actionData); | ||
} | ||
} | ||
if (packet.getInputData().contains(PlayerAuthInputData.IN_CLIENT_PREDICTED_IN_VEHICLE)) { | ||
helper.writeVector2f(buffer, packet.getVehicleRotation()); | ||
VarInts.writeLong(buffer, packet.getPredictedVehicle()); | ||
} | ||
helper.writeVector2f(buffer, packet.getAnalogMoveVector()); | ||
helper.writeVector3f(buffer, packet.getCameraOrientation()); | ||
helper.writeVector2f(buffer, packet.getRawMoveVector()); | ||
} | ||
|
||
@Override | ||
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, PlayerAuthInputPacket packet) { | ||
float x = buffer.readFloatLE(); | ||
float y = buffer.readFloatLE(); | ||
packet.setPosition(helper.readVector3f(buffer)); | ||
packet.setMotion(Vector2f.from(buffer.readFloatLE(), buffer.readFloatLE())); | ||
float z = buffer.readFloatLE(); | ||
packet.setRotation(Vector3f.from(x, y, z)); | ||
helper.readLargeVarIntFlags(buffer, packet.getInputData(), PlayerAuthInputData.class); | ||
packet.setInputMode(INPUT_MODES[VarInts.readUnsignedInt(buffer)]); | ||
packet.setPlayMode(CLIENT_PLAY_MODES[VarInts.readUnsignedInt(buffer)]); | ||
readInteractionModel(buffer, helper, packet); | ||
packet.setInteractRotation(helper.readVector2f(buffer)); | ||
packet.setTick(VarInts.readUnsignedLong(buffer)); | ||
packet.setDelta(helper.readVector3f(buffer)); | ||
if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_INTERACTION)) { | ||
packet.setItemUseTransaction(this.readItemUseTransaction(buffer, helper)); | ||
} | ||
if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_STACK_REQUEST)) { | ||
packet.setItemStackRequest(helper.readItemStackRequest(buffer)); | ||
} | ||
if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_BLOCK_ACTIONS)) { | ||
helper.readArray(buffer, packet.getPlayerActions(), VarInts::readInt, this::readPlayerBlockActionData, 32); // 32 is more than enough | ||
} | ||
if (packet.getInputData().contains(PlayerAuthInputData.IN_CLIENT_PREDICTED_IN_VEHICLE)) { | ||
packet.setVehicleRotation(helper.readVector2f(buffer)); | ||
packet.setPredictedVehicle(VarInts.readLong(buffer)); | ||
} | ||
packet.setAnalogMoveVector(helper.readVector2f(buffer)); | ||
packet.setCameraOrientation(helper.readVector3f(buffer)); | ||
packet.setRawMoveVector(helper.readVector2f(buffer)); | ||
} | ||
} |
Oops, something went wrong.
@Alemiz112 Hey, I found a few missing things in this commit: the protocol version should be 766 and the changes to the CameraPreset type (tracking radius & CameraPresetAimAssistDefinition) are missing. Changes to the ParticleType enumeration are missing and FilteredCustomName should be added to the ItemStackResponseSlotInfo type.