Skip to content

Commit

Permalink
Start working on MCBE 1.20.50 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed Nov 7, 2023
1 parent e478e2f commit 4dd30b7
Show file tree
Hide file tree
Showing 22 changed files with 394 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.cloudburstmc.protocol.bedrock.codec.v630;

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.v575.BedrockCodecHelper_v575;
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
import org.cloudburstmc.protocol.bedrock.codec.v630.serializer.ServerPostMovePositionSerializer_v630;
import org.cloudburstmc.protocol.bedrock.codec.v630.serializer.SetPlayerInventoryOptionsSerializer_v360;
import org.cloudburstmc.protocol.bedrock.codec.v630.serializer.ShowStoreOfferSerializer_v630;
import org.cloudburstmc.protocol.bedrock.codec.v630.serializer.ToggleCrafterSlotRequestSerializer_v630;
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
import org.cloudburstmc.protocol.bedrock.data.LevelEventType;
import org.cloudburstmc.protocol.bedrock.data.ParticleType;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerSlotType;
import org.cloudburstmc.protocol.bedrock.packet.*;
import org.cloudburstmc.protocol.common.util.TypeMap;

public class Bedrock_v630 extends Bedrock_v622 {

protected static final TypeMap<ParticleType> PARTICLE_TYPES = Bedrock_v622.PARTICLE_TYPES
.toBuilder()
.insert(87, ParticleType.DUST_PLUME)
.insert(88, ParticleType.WHITE_SMOKE)
.build();

protected static final TypeMap<LevelEventType> LEVEL_EVENTS = Bedrock_v622.LEVEL_EVENTS.toBuilder()
.insert(LEVEL_EVENT_PARTICLE + 40, LevelEvent.DUST_PLUME)
.replace(LEVEL_EVENT_BLOCK + 109, LevelEvent.PARTICLE_SHOOT_WHITE_SMOKE)
.insert(LEVEL_EVENT_BLOCK + 110, LevelEvent.ALL_PLAYERS_SLEEPING)
.insert(LEVEL_EVENT_PARTICLE_TYPE, PARTICLE_TYPES)
.build();

protected static final TypeMap<ContainerSlotType> CONTAINER_SLOT_TYPES = Bedrock_v622.CONTAINER_SLOT_TYPES.toBuilder()
.insert(62, ContainerSlotType.CRAFTER_BLOCK_CONTAINER)
.build();

protected static final TypeMap<SoundEvent> SOUND_EVENTS = Bedrock_v622.SOUND_EVENTS
.toBuilder()
.replace(479, SoundEvent.CRAFTER_CRAFT)
.insert(480, SoundEvent.CRAFTER_FAILED)
.insert(481, SoundEvent.DECORATED_POT_INSERT)
.insert(482, SoundEvent.DECORATED_POT_INSERT_FAILED)
.insert(483, SoundEvent.CRAFTER_DISABLE_SLOT)
.insert(490, SoundEvent.COPPER_BULB_ON)
.insert(491, SoundEvent.COPPER_BULB_OFF)
.insert(492, SoundEvent.UNDEFINED)
.build();


public static final BedrockCodec CODEC = Bedrock_v622.CODEC.toBuilder()
.raknetProtocolVersion(11)
.protocolVersion(630)
.minecraftVersion("1.20.50")
.helper(() -> new BedrockCodecHelper_v575(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(ShowStoreOfferPacket.class, ShowStoreOfferSerializer_v630.INSTANCE)
.registerPacket(ServerPostMovePositionPacket::new, new ServerPostMovePositionSerializer_v630(), 16)
.registerPacket(ToggleCrafterSlotRequestPacket::new, new ToggleCrafterSlotRequestSerializer_v630(), 306)
.registerPacket(SetPlayerInventoryOptionsPacket::new, new SetPlayerInventoryOptionsSerializer_v360(), 307)
.build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.cloudburstmc.protocol.bedrock.codec.v630.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.packet.ServerPostMovePositionPacket;

public class ServerPostMovePositionSerializer_v630 implements BedrockPacketSerializer<ServerPostMovePositionPacket> {

@Override
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, ServerPostMovePositionPacket packet) {
helper.writeVector3f(buffer, packet.getPosition());
}

@Override
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, ServerPostMovePositionPacket packet) {
packet.setPosition(helper.readVector3f(buffer));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.cloudburstmc.protocol.bedrock.codec.v630.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.inventory.InventoryLayout;
import org.cloudburstmc.protocol.bedrock.data.inventory.InventoryTabLeft;
import org.cloudburstmc.protocol.bedrock.data.inventory.InventoryTabRight;
import org.cloudburstmc.protocol.bedrock.packet.SetPlayerInventoryOptionsPacket;
import org.cloudburstmc.protocol.common.util.VarInts;

public class SetPlayerInventoryOptionsSerializer_v360 implements BedrockPacketSerializer<SetPlayerInventoryOptionsPacket> {

@Override
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, SetPlayerInventoryOptionsPacket packet) {
VarInts.writeInt(buffer, packet.getLeftTab().ordinal());
VarInts.writeInt(buffer, packet.getRightTab().ordinal());
buffer.writeBoolean(packet.isFiltering());
VarInts.writeInt(buffer, packet.getLayout().ordinal());
VarInts.writeInt(buffer, packet.getCraftingLayout().ordinal());
}

@Override
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, SetPlayerInventoryOptionsPacket packet) {
packet.setLeftTab(InventoryTabLeft.VALUES[VarInts.readInt(buffer)]);
packet.setRightTab(InventoryTabRight.VALUES[VarInts.readInt(buffer)]);
packet.setFiltering(buffer.readBoolean());
packet.setLayout(InventoryLayout.VALUES[VarInts.readInt(buffer)]);
packet.setCraftingLayout(InventoryLayout.VALUES[VarInts.readInt(buffer)]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.cloudburstmc.protocol.bedrock.codec.v630.serializer;

import io.netty.buffer.ByteBuf;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
import org.cloudburstmc.protocol.bedrock.codec.v291.serializer.ShowStoreOfferSerializer_v291;
import org.cloudburstmc.protocol.bedrock.data.StoreOfferRedirectType;
import org.cloudburstmc.protocol.bedrock.packet.ShowStoreOfferPacket;

public class ShowStoreOfferSerializer_v630 extends ShowStoreOfferSerializer_v291 {
public static final ShowStoreOfferSerializer_v630 INSTANCE = new ShowStoreOfferSerializer_v630();

@Override
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, ShowStoreOfferPacket packet) {
helper.writeString(buffer, packet.getOfferId());
buffer.writeByte(packet.getRedirectType().ordinal());
}

@Override
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, ShowStoreOfferPacket packet) {
packet.setOfferId(helper.readString(buffer));
packet.setRedirectType(StoreOfferRedirectType.values()[buffer.readUnsignedByte()]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.cloudburstmc.protocol.bedrock.codec.v630.serializer;

import io.netty.buffer.ByteBuf;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
import org.cloudburstmc.protocol.bedrock.codec.BedrockPacketSerializer;
import org.cloudburstmc.protocol.bedrock.packet.ToggleCrafterSlotRequestPacket;

public class ToggleCrafterSlotRequestSerializer_v630 implements BedrockPacketSerializer<ToggleCrafterSlotRequestPacket> {

@Override
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, ToggleCrafterSlotRequestPacket packet) {
buffer.writeIntLE(packet.getBlockPosition().getX());
buffer.writeIntLE(packet.getBlockPosition().getY());
buffer.writeIntLE(packet.getBlockPosition().getZ());
buffer.writeByte(packet.getSlot());
buffer.writeBoolean(packet.isDisabled());
}

@Override
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, ToggleCrafterSlotRequestPacket packet) {
int x = buffer.readIntLE();
int y = buffer.readIntLE();
int z = buffer.readIntLE();
packet.setBlockPosition(Vector3i.from(x, y, z));
packet.setSlot(buffer.readByte());
packet.setDisabled(buffer.readBoolean());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,17 @@ public enum DisconnectFailReason {
CONN_INACTIVITY_TIMEOUT,
STALE_CONNECTION_BEING_REPLACED,
REALMS_SESSION_NOT_FOUND,
BAD_PACKET
BAD_PACKET,
CONN_FAILED_TO_CREATE_OFFER,
CONN_FAILED_TO_CREATE_ANSWER,
CONN_FAILED_TO_SET_LOCAL_DESCRIPTION,
CONN_FAILED_TO_SET_REMOTE_DESCRIPTION,
CONN_NEGOTIATION_TIMEOUT_WAITING_FOR_RESPONSE,
CONN_NEGOTIATION_TIMEOUT_WAITING_FOR_ACCEPT,
CONN_INCOMING_CONNECTION_IGNORED,
CONN_SIGNALING_PARSING_FAILURE,
CONN_SIGNALING_UNKNOWN_ERROR,
CONN_SIGNALING_UNICAST_DELIVERY_FAILED,
CONN_SIGNALING_BROADCAST_DELIVERY_FAILED,
CONN_SIGNALING_GENERIC_DELIVERY_FAILED
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,18 @@ public enum LevelEvent implements LevelEventType {
PARTICLE_BREAK_BLOCK_SOUTH,
PARTICLE_BREAK_BLOCK_WEST,
PARTICLE_BREAK_BLOCK_EAST,
/**
* @since v630
*/
PARTICLE_SHOOT_WHITE_SMOKE,
SCULK_CATALYST_BLOOM,
SCULK_CHARGE,
SCULK_CHARGE_POP,
SONIC_EXPLOSION,
/**
* @since v630
*/
DUST_PLUME,

// world
START_RAINING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,13 @@ public enum ParticleType implements LevelEventType {
/**
* @since v618
*/
CHERRY_LEAVES
CHERRY_LEAVES,
/**
* @since v630
*/
DUST_PLUME,
/**
* @since v630
*/
WHITE_SMOKE
}
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,34 @@ public enum SoundEvent {
* @since v622
*/
BOTTLE_EMPTY,
/**
* @since v630
*/
CRAFTER_CRAFT,
/**
* @since v630
*/
CRAFTER_FAILED,
/**
* @since v630
*/
CRAFTER_DISABLE_SLOT,
/**
* @since v630
*/
DECORATED_POT_INSERT,
/**
* @since v630
*/
DECORATED_POT_INSERT_FAILED,
/**
* @since v630
*/
COPPER_BULB_ON,
/**
* @since v630
*/
COPPER_BULB_OFF,

UNDEFINED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.cloudburstmc.protocol.bedrock.data;

public enum StoreOfferRedirectType {
MARKETPLACE,
DRESSING_ROOM,
THIRD_PARTY_SERVER_PAGE
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ public enum ContainerSlotType {
CURSOR,
CREATED_OUTPUT,
RECIPE_BOOK,
SMITHING_TABLE_TEMPLATE
SMITHING_TABLE_TEMPLATE,
/**
* @since v630
*/
CRAFTER_BLOCK_CONTAINER
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ public enum ContainerType {
HUD(31),
JIGSAW_EDITOR(32),
SMITHING_TABLE(33),
CHEST_BOAT(34);
CHEST_BOAT(34),
/**
* @since v630
*/
DECORATED_POT(35),
/**
* @since v630
*/
CRAFTER(36);

public static final ContainerType[] VALUES;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.cloudburstmc.protocol.bedrock.data.inventory;

public enum InventoryLayout {
NONE,
SURVIVAL,
RECIPE_BOOK,
CREATIVE;

public static final InventoryLayout[] VALUES = values();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.cloudburstmc.protocol.bedrock.data.inventory;

public enum InventoryTabLeft {
NONE,
RECIPE_CONSTRUCTION,
RECIPE_EQUIPMENT,
RECIPE_ITEMS,
RECIPE_NATURE,
RECIPE_SEARCH,
SURVIVAL;

public static final InventoryTabLeft[] VALUES = values();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.cloudburstmc.protocol.bedrock.data.inventory;

public enum InventoryTabRight {
NONE,
FULL_SCREEN,
CRAFTING,
ARMOR;

public static final InventoryTabRight[] VALUES = values();
}
Original file line number Diff line number Diff line change
Expand Up @@ -823,4 +823,16 @@ default PacketSignal handle(AgentAnimationPacket packet) {
default PacketSignal handle(RefreshEntitlementsPacket packet) {
return PacketSignal.UNHANDLED;
}

default PacketSignal handle(ServerPostMovePositionPacket packet) {
return PacketSignal.UNHANDLED;
}

default PacketSignal handle(ToggleCrafterSlotRequestPacket packet) {
return PacketSignal.UNHANDLED;
}

default PacketSignal handle(SetPlayerInventoryOptionsPacket packet) {
return PacketSignal.UNHANDLED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,8 @@ public enum BedrockPacketType {
TRIM_DATA,
OPEN_SIGN,
AGENT_ANIMATION,
REFRESH_ENTITLEMENTS
REFRESH_ENTITLEMENTS,
SERVER_POST_MOVE_POSITION,
TOGGLE_CRAFTER_SLOT_REQUEST,
SET_PLAYER_INVENTORY_OPTIONS
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import java.util.List;
import java.util.UUID;

/**
* @since since v630
*/
@Deprecated
@Data
@EqualsAndHashCode(doNotUseGetters = true)
@ToString(doNotUseGetters = true)
Expand Down
Loading

0 comments on commit 4dd30b7

Please sign in to comment.