Skip to content

Commit 5e6cad4

Browse files
committed
Start working on v924
1 parent 98d0fcb commit 5e6cad4

File tree

44 files changed

+1324
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1324
-33
lines changed

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/BookEditSerializer_v291.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@NoArgsConstructor(access = AccessLevel.PROTECTED)
1515
public class BookEditSerializer_v291 implements BedrockPacketSerializer<BookEditPacket> {
1616
public static final BookEditSerializer_v291 INSTANCE = new BookEditSerializer_v291();
17-
private static final Int2ObjectBiMap<Action> types = new Int2ObjectBiMap<>();
17+
protected static final Int2ObjectBiMap<Action> types = new Int2ObjectBiMap<>();
1818

1919
static {
2020
types.put(0, Action.REPLACE_PAGE);

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v800/serializer/BiomeDefinitionListSerializer_v800.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ protected BiomeDefinitionChunkGenData readDefinitionChunkGen(ByteBuf buffer, Bed
171171
hasFrozenOceanSurface, hasTheEndSurface,
172172
mesaSurface, cappedSurface,
173173
overworldGenRules, multinoiseGenRules,
174-
legacyWorldGenRules, null);
174+
legacyWorldGenRules, null, null);
175175
}
176176

177177
protected void writeClimate(ByteBuf buffer, BedrockCodecHelper helper, BiomeClimateData climate) {

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v818/serializer/DebugDrawerSerializer_v818.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, DebugDrawerPa
4444
}
4545

4646
protected void writeShape(ByteBuf buffer, BedrockCodecHelper helper, DebugShape shape) {
47-
VarInts.writeUnsignedLong(buffer, shape.getId());
4847
writeCommonShapeData(buffer, helper, shape);
4948

5049
switch (shape.getType()) {
@@ -106,6 +105,7 @@ protected void writeShape(ByteBuf buffer, BedrockCodecHelper helper, DebugShape
106105
}
107106

108107
protected void writeCommonShapeData(ByteBuf buffer, BedrockCodecHelper helper, DebugShape shape) {
108+
VarInts.writeUnsignedLong(buffer, shape.getId());
109109
helper.writeOptionalNull(buffer, shape.getType(), (buf, type) -> buf.writeByte(type.ordinal()));
110110
helper.writeOptionalNull(buffer, shape.getPosition(), WRITE_VECTOR3F);
111111
helper.writeOptionalNull(buffer, shape.getScale(), ByteBuf::writeFloatLE);

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v844/serializer/BiomeDefinitionListSerializer_v844.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected BiomeDefinitionChunkGenData readDefinitionChunkGen(ByteBuf buffer, Bed
116116
hasFrozenOceanSurface, hasTheEndSurface,
117117
mesaSurface, cappedSurface,
118118
overworldGenRules, multinoiseGenRules,
119-
legacyWorldGenRules, null);
119+
legacyWorldGenRules, null, null);
120120
}
121121

122122
@Override

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v859/serializer/BiomeDefinitionListSerializer_v859.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected BiomeDefinitionChunkGenData readDefinitionChunkGen(ByteBuf buffer, Bed
4848
hasFrozenOceanSurface, hasTheEndSurface,
4949
mesaSurface, cappedSurface,
5050
overworldGenRules, multinoiseGenRules,
51-
legacyWorldGenRules, replacementData);
51+
legacyWorldGenRules, replacementData, null);
5252
}
5353

5454
protected void writeBiomeReplacementData(ByteBuf buffer, BedrockCodecHelper helper, BiomeReplacementData replacementData) {

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v859/serializer/CameraInstructionSerializer_v859.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package org.cloudburstmc.protocol.bedrock.codec.v859.serializer;
22

33
import io.netty.buffer.ByteBuf;
4-
import org.cloudburstmc.math.vector.Vector2f;
54
import org.cloudburstmc.math.vector.Vector3f;
65
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
76
import org.cloudburstmc.protocol.bedrock.codec.v827.serializer.CameraInstructionSerializer_v827;
87
import org.cloudburstmc.protocol.bedrock.data.camera.CameraAttachToEntityInstruction;
8+
import org.cloudburstmc.protocol.bedrock.data.camera.CameraEase;
99
import org.cloudburstmc.protocol.bedrock.data.camera.CameraSplineInstruction;
1010
import org.cloudburstmc.protocol.bedrock.data.camera.CameraSplineType;
1111
import org.cloudburstmc.protocol.bedrock.packet.CameraInstructionPacket;
@@ -25,7 +25,10 @@ public void serialize(ByteBuf buffer, BedrockCodecHelper helper, CameraInstructi
2525
buf.writeFloatLE(splineInstruction.getTotalTime());
2626
buf.writeByte(splineInstruction.getType().ordinal());
2727
helper.writeArray(buf, splineInstruction.getCurve(), helper::writeVector3f);
28-
helper.writeArray(buf, splineInstruction.getProgressKeyFrames(), helper::writeVector2f);
28+
helper.writeArray(buf, splineInstruction.getProgressKeyFrames(), (buf2, frame) -> {
29+
buf2.writeFloatLE(frame.getValue());
30+
buf2.writeFloatLE(frame.getTime());
31+
});
2932
helper.writeArray(buf, splineInstruction.getRotationOption(), (buf2, rotationOption) -> {
3033
helper.writeVector3f(buf2, rotationOption.getKeyFrameValues());
3134
buf2.writeFloatLE(rotationOption.getKeyFrameTimes());
@@ -43,8 +46,12 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, CameraInstruc
4346
CameraSplineType type = CameraSplineType.values()[buf.readUnsignedByte()];
4447
List<Vector3f> curve = new ArrayList<>();
4548
helper.readArray(buf, curve, helper::readVector3f);
46-
List<Vector2f> progressKeyFrames = new ArrayList<>();
47-
helper.readArray(buf, progressKeyFrames, helper::readVector2f);
49+
List<CameraSplineInstruction.SplineProgressOption> progressKeyFrames = new ArrayList<>();
50+
helper.readArray(buf, progressKeyFrames, buf2 -> {
51+
float value = buf2.readFloatLE();
52+
float time = buf2.readFloatLE();
53+
return new CameraSplineInstruction.SplineProgressOption(value, time, CameraEase.LINEAR);
54+
});
4855
List<CameraSplineInstruction.SplineRotationOption> rotationOption = new ArrayList<>();
4956
helper.readArray(buf, rotationOption, buf2 -> {
5057
Vector3f keyFrameValues = helper.readVector3f(buf2);

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v859/serializer/DebugDrawerSerializer_v859.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ protected int toPayloadType(DebugShape.Type type) {
3131

3232
@Override
3333
protected void writeShape(ByteBuf buffer, BedrockCodecHelper helper, DebugShape shape) {
34-
VarInts.writeUnsignedLong(buffer, shape.getId());
3534
writeCommonShapeData(buffer, helper, shape);
36-
VarInts.writeInt(buffer, shape.getDimension());
3735

3836
DebugShape.Type type = shape.getType();
3937
VarInts.writeUnsignedInt(buffer, toPayloadType(type));
@@ -72,6 +70,13 @@ protected void writeShape(ByteBuf buffer, BedrockCodecHelper helper, DebugShape
7270
}
7371
}
7472

73+
@Override
74+
protected void writeCommonShapeData(ByteBuf buffer, BedrockCodecHelper helper, DebugShape shape) {
75+
super.writeCommonShapeData(buffer, helper, shape);
76+
77+
VarInts.writeInt(buffer, shape.getDimension());
78+
}
79+
7580
@Override
7681
protected DebugShape readShape(ByteBuf buffer, BedrockCodecHelper helper) {
7782
long id = VarInts.readUnsignedLong(buffer);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package org.cloudburstmc.protocol.bedrock.codec.v924;
2+
3+
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
4+
import org.cloudburstmc.protocol.bedrock.codec.EntityDataTypeMap;
5+
import org.cloudburstmc.protocol.bedrock.codec.v786.serializer.LevelSoundEventSerializer_v786;
6+
import org.cloudburstmc.protocol.bedrock.codec.v898.BedrockCodecHelper_v898;
7+
import org.cloudburstmc.protocol.bedrock.codec.v898.Bedrock_v898;
8+
import org.cloudburstmc.protocol.bedrock.codec.v924.serializer.*;
9+
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
10+
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataFormat;
11+
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
12+
import org.cloudburstmc.protocol.bedrock.packet.*;
13+
import org.cloudburstmc.protocol.common.util.TypeMap;
14+
15+
public class Bedrock_v924 extends Bedrock_v898 {
16+
17+
protected static final EntityDataTypeMap ENTITY_DATA = Bedrock_v898.ENTITY_DATA
18+
.toBuilder()
19+
.insert(EntityDataTypes.AIM_ASSIST_PRIORITY_PRESET_ID, 136, EntityDataFormat.INT)
20+
.insert(EntityDataTypes.AIM_ASSIST_PRIORITY_CATEGORY_ID, 137, EntityDataFormat.INT)
21+
.insert(EntityDataTypes.AIM_ASSIST_PRIORITY_ACTOR_ID, 138, EntityDataFormat.INT)
22+
.build();
23+
24+
protected static final TypeMap<SoundEvent> SOUND_EVENTS = Bedrock_v898.SOUND_EVENTS
25+
.toBuilder()
26+
.replace(578, SoundEvent.SADDLE_IN_WATER)
27+
.insert(579, SoundEvent.STONE_SPEAR_ATTACK_HIT)
28+
.insert(580, SoundEvent.IRON_SPEAR_ATTACK_HIT)
29+
.insert(581, SoundEvent.COPPER_SPEAR_ATTACK_HIT)
30+
.insert(582, SoundEvent.GOLDEN_SPEAR_ATTACK_HIT)
31+
.insert(583, SoundEvent.DIAMOND_SPEAR_ATTACK_HIT)
32+
.insert(584, SoundEvent.NETHERITE_SPEAR_ATTACK_HIT)
33+
.insert(585, SoundEvent.STONE_SPEAR_ATTACK_MISS)
34+
.insert(586, SoundEvent.IRON_SPEAR_ATTACK_MISS)
35+
.insert(587, SoundEvent.COPPER_SPEAR_ATTACK_MISS)
36+
.insert(588, SoundEvent.GOLDEN_SPEAR_ATTACK_MISS)
37+
.insert(589, SoundEvent.DIAMOND_SPEAR_ATTACK_MISS)
38+
.insert(590, SoundEvent.NETHERITE_SPEAR_ATTACK_MISS)
39+
.insert(591, SoundEvent.STONE_SPEAR_USE)
40+
.insert(592, SoundEvent.IRON_SPEAR_USE)
41+
.insert(593, SoundEvent.COPPER_SPEAR_USE)
42+
.insert(594, SoundEvent.GOLDEN_SPEAR_USE)
43+
.insert(595, SoundEvent.DIAMOND_SPEAR_USE)
44+
.insert(596, SoundEvent.NETHERITE_SPEAR_USE)
45+
.insert(597, SoundEvent.UNDEFINED)
46+
47+
.build();
48+
49+
public static final BedrockCodec CODEC = Bedrock_v898.CODEC.toBuilder()
50+
.protocolVersion(924)
51+
.minecraftVersion("1.26.0")
52+
.helper(() -> new BedrockCodecHelper_v898(ENTITY_DATA, GAME_RULE_TYPES, ITEM_STACK_REQUEST_TYPES, CONTAINER_SLOT_TYPES, PLAYER_ABILITIES, TEXT_PROCESSING_ORIGINS))
53+
.updateSerializer(BiomeDefinitionListPacket.class, BiomeDefinitionListSerializer_v924.INSTANCE)
54+
.updateSerializer(BookEditPacket.class, BookEditSerializer_v924.INSTANCE)
55+
.updateSerializer(CameraAimAssistPresetsPacket.class, CameraAimAssistPresetsSerializer_v924.INSTANCE)
56+
.updateSerializer(CameraInstructionPacket.class, CameraInstructionSerializer_v924.INSTANCE)
57+
.updateSerializer(ClientboundDataStorePacket.class, ClientboundDataStoreSerializer_v924.INSTANCE)
58+
.updateSerializer(DebugDrawerPacket.class, DebugDrawerSerializer_v924.INSTANCE)
59+
.updateSerializer(GraphicsParameterOverridePacket.class, GraphicsParameterOverrideSerializer_v924.INSTANCE)
60+
.updateSerializer(LevelSoundEventPacket.class, new LevelSoundEventSerializer_v786(SOUND_EVENTS))
61+
.updateSerializer(ServerboundDataStorePacket.class, ServerboundDataStoreSerializer_v924.INSTANCE)
62+
.updateSerializer(ServerboundDiagnosticsPacket.class, ServerboundDiagnosticsSerializer_v924.INSTANCE)
63+
.updateSerializer(StartGamePacket.class, StartGameSerializer_v924.INSTANCE)
64+
.updateSerializer(TextPacket.class, TextSerializer_v924.INSTANCE)
65+
.build();
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.cloudburstmc.protocol.bedrock.codec.v924.serializer;
2+
3+
import io.netty.buffer.ByteBuf;
4+
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
5+
import org.cloudburstmc.protocol.bedrock.codec.v859.serializer.BiomeDefinitionListSerializer_v859;
6+
import org.cloudburstmc.protocol.bedrock.data.biome.*;
7+
import org.cloudburstmc.protocol.common.util.SequencedHashSet;
8+
9+
import java.util.List;
10+
11+
public class BiomeDefinitionListSerializer_v924 extends BiomeDefinitionListSerializer_v859 {
12+
13+
public static final BiomeDefinitionListSerializer_v924 INSTANCE = new BiomeDefinitionListSerializer_v924();
14+
15+
@Override
16+
protected void writeDefinitionChunkGen(ByteBuf buffer, BedrockCodecHelper helper, BiomeDefinitionChunkGenData definitionChunkGen,
17+
SequencedHashSet<String> strings) {
18+
super.writeDefinitionChunkGen(buffer, helper, definitionChunkGen, strings);
19+
helper.writeOptionalNull(buffer, definitionChunkGen.getVillageType(), (b, n) -> b.writeByte(n.intValue()));
20+
}
21+
22+
@Override
23+
protected BiomeDefinitionChunkGenData readDefinitionChunkGen(ByteBuf buffer, BedrockCodecHelper helper, List<String> strings) {
24+
BiomeClimateData climate = helper.readOptional(buffer, null, this::readClimate);
25+
List<BiomeConsolidatedFeatureData> consolidatedFeatures = helper.readOptional(buffer, null,
26+
(buf, aHelper) -> this.readConsolidatedFeatures(buf, aHelper, strings));
27+
BiomeMountainParamsData mountainParams = helper.readOptional(buffer, null, this::readMountainParamsData);
28+
BiomeSurfaceMaterialAdjustmentData surfaceMaterialAdjustment = helper.readOptional(buffer, null,
29+
(buf, aHelper) -> this.readSurfaceMaterialAdjustment(buf, aHelper, strings));
30+
BiomeSurfaceMaterialData surfaceMaterial = helper.readOptional(buffer, null, this::readSurfaceMaterial);
31+
boolean hasDefaultOverworldSurface = buffer.readBoolean();
32+
boolean hasSwampSurface = buffer.readBoolean();
33+
boolean hasFrozenOceanSurface = buffer.readBoolean();
34+
boolean hasTheEndSurface = buffer.readBoolean();
35+
BiomeMesaSurfaceData mesaSurface = helper.readOptional(buffer, null, this::readMesaSurface);
36+
BiomeCappedSurfaceData cappedSurface = helper.readOptional(buffer, null, this::readCappedSurface);
37+
BiomeOverworldGenRulesData overworldGenRules = helper.readOptional(buffer, null,
38+
(buf, aHelper) -> this.readOverworldGenRules(buf, aHelper, strings));
39+
BiomeMultinoiseGenRulesData multinoiseGenRules = helper.readOptional(buffer, null, this::readMultinoiseGenRules);
40+
BiomeLegacyWorldGenRulesData legacyWorldGenRules = helper.readOptional(buffer, null,
41+
(buf, aHelper) -> this.readLegacyWorldGenRules(buf, aHelper, strings));
42+
BiomeReplacementData replacementData = helper.readOptional(buffer, null, this::readBiomeReplacementData);
43+
Number villageType = helper.readOptional(buffer, null, ByteBuf::readUnsignedByte);
44+
45+
return new BiomeDefinitionChunkGenData(climate, consolidatedFeatures,
46+
mountainParams, surfaceMaterialAdjustment,
47+
surfaceMaterial, hasDefaultOverworldSurface, hasSwampSurface,
48+
hasFrozenOceanSurface, hasTheEndSurface,
49+
mesaSurface, cappedSurface,
50+
overworldGenRules, multinoiseGenRules,
51+
legacyWorldGenRules, replacementData, villageType);
52+
}
53+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.cloudburstmc.protocol.bedrock.codec.v924.serializer;
2+
3+
import io.netty.buffer.ByteBuf;
4+
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
5+
import org.cloudburstmc.protocol.bedrock.codec.v291.serializer.BookEditSerializer_v291;
6+
import org.cloudburstmc.protocol.bedrock.packet.BookEditPacket;
7+
import org.cloudburstmc.protocol.common.util.TextConverter;
8+
import org.cloudburstmc.protocol.common.util.VarInts;
9+
10+
public class BookEditSerializer_v924 extends BookEditSerializer_v291 {
11+
12+
public static final BookEditSerializer_v924 INSTANCE = new BookEditSerializer_v924();
13+
14+
@Override
15+
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, BookEditPacket packet) {
16+
VarInts.writeInt(buffer, packet.getInventorySlot());
17+
VarInts.writeUnsignedInt(buffer, packet.getAction().ordinal());
18+
19+
TextConverter converter = helper.getTextConverter();
20+
switch (packet.getAction()) {
21+
case REPLACE_PAGE:
22+
case ADD_PAGE:
23+
VarInts.writeInt(buffer, packet.getPageNumber());
24+
helper.writeString(buffer, converter.serialize(packet.getText(CharSequence.class)));
25+
helper.writeString(buffer, packet.getPhotoName());
26+
break;
27+
case DELETE_PAGE:
28+
VarInts.writeInt(buffer, packet.getPageNumber());
29+
break;
30+
case SWAP_PAGES:
31+
VarInts.writeInt(buffer, packet.getPageNumber());
32+
VarInts.writeInt(buffer, packet.getSecondaryPageNumber());
33+
break;
34+
case SIGN_BOOK:
35+
helper.writeString(buffer, converter.serialize(packet.getTitle(CharSequence.class)));
36+
helper.writeString(buffer, converter.serialize(packet.getAuthor(CharSequence.class)));
37+
helper.writeString(buffer, packet.getXuid());
38+
break;
39+
}
40+
}
41+
42+
@Override
43+
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, BookEditPacket packet) {
44+
packet.setInventorySlot(VarInts.readInt(buffer));
45+
packet.setAction(types.get(VarInts.readUnsignedInt(buffer)));
46+
47+
TextConverter converter = helper.getTextConverter();
48+
switch (packet.getAction()) {
49+
case REPLACE_PAGE:
50+
case ADD_PAGE:
51+
packet.setPageNumber(VarInts.readInt(buffer));
52+
packet.setText(converter.deserialize(helper.readString(buffer)));
53+
packet.setPhotoName(helper.readString(buffer));
54+
break;
55+
case DELETE_PAGE:
56+
packet.setPageNumber(VarInts.readInt(buffer));
57+
break;
58+
case SWAP_PAGES:
59+
packet.setPageNumber(VarInts.readInt(buffer));
60+
packet.setSecondaryPageNumber(VarInts.readInt(buffer));
61+
break;
62+
case SIGN_BOOK:
63+
packet.setTitle(converter.deserialize(helper.readString(buffer)));
64+
packet.setAuthor(converter.deserialize(helper.readString(buffer)));
65+
packet.setXuid(helper.readString(buffer));
66+
break;
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)