Skip to content

Commit

Permalink
Merge pull request #734 from GeyserMC/feature/1.20
Browse files Browse the repository at this point in the history
1.20 support
  • Loading branch information
Redned235 authored Jun 7, 2023
2 parents d2803b7 + 4e72a93 commit caa35c7
Show file tree
Hide file tree
Showing 28 changed files with 85 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
- feature/math-2.0 #TEMPOARY
- feature/1.20 #TEMPOARY

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>1.19.4-2-SNAPSHOT</version>
<version>1.20-1</version>
<packaging>jar</packaging>

<name>MCProtocolLib</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ public class MinecraftCodec {
}

public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion(762)
.protocolVersion(763)
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
.minecraftVersion("1.19.4")
.minecraftVersion("1.20")
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
.registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,6 @@ public void writeBlockEntityType(ByteBuf buf, BlockEntityType type) {
}

public LightUpdateData readLightUpdateData(ByteBuf buf) {
boolean trustEdges = buf.readBoolean();

BitSet skyYMask = BitSet.valueOf(this.readLongArray(buf));
BitSet blockYMask = BitSet.valueOf(this.readLongArray(buf));
BitSet emptySkyYMask = BitSet.valueOf(this.readLongArray(buf));
Expand All @@ -597,12 +595,10 @@ public LightUpdateData readLightUpdateData(ByteBuf buf) {
blockUpdates.add(this.readByteArray(buf));
}

return new LightUpdateData(skyYMask, blockYMask, emptySkyYMask, emptyBlockYMask, skyUpdates, blockUpdates, trustEdges);
return new LightUpdateData(skyYMask, blockYMask, emptySkyYMask, emptyBlockYMask, skyUpdates, blockUpdates);
}

public void writeLightUpdateData(ByteBuf buf, LightUpdateData data) {
buf.writeBoolean(data.isTrustEdges());

writeBitSet(buf, data.getSkyYMask());
writeBitSet(buf, data.getBlockYMask());
writeBitSet(buf, data.getEmptySkyYMask());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ public class Advancement {
private final @NonNull List<List<String>> requirements;
private final String parentId;
private final DisplayData displayData;
private final boolean sendsTelemetryEvent;

public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements) {
this(id, criteria, requirements, null, null);
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, boolean sendsTelemetryEvent) {
this(id, criteria, requirements, null, null, sendsTelemetryEvent);
}

public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, String parentId) {
this(id, criteria, requirements, parentId, null);
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, String parentId, boolean sendsTelemetryEvent) {
this(id, criteria, requirements, parentId, null, sendsTelemetryEvent);
}

public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, DisplayData displayData) {
this(id, criteria, requirements, null, displayData);
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, DisplayData displayData, boolean sendsTelemetryEvent) {
this(id, criteria, requirements, null, displayData, sendsTelemetryEvent);
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public enum ContainerType {
LOOM,
MERCHANT,
SHULKER_BOX,
LEGACY_SMITHING,
SMITHING,
SMOKER,
CARTOGRAPHY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ public class LightUpdateData {
private final @NonNull BitSet emptyBlockYMask;
private final @NonNull List<byte[]> skyUpdates;
private final @NonNull List<byte[]> blockUpdates;
private final boolean trustEdges;

public static LightUpdateData read(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
return new LightUpdateData(in, helper);
}

private LightUpdateData(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.trustEdges = in.readBoolean();

this.skyYMask = BitSet.valueOf(helper.readLongArray(in));
this.blockYMask = BitSet.valueOf(helper.readLongArray(in));
this.emptySkyYMask = BitSet.valueOf(helper.readLongArray(in));
Expand All @@ -52,8 +49,6 @@ public static void write(ByteBuf out, MinecraftCodecHelper helper, LightUpdateDa
}

private void write(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
out.writeBoolean(this.trustEdges);

writeBitSet(out, helper, this.skyYMask);
writeBitSet(out, helper, this.blockYMask);
writeBitSet(out, helper, this.emptySkyYMask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ public enum BlockEntityType {
CAMPFIRE,
BEEHIVE,
SCULK_SENSOR,
CALIBRATED_SCULK_SENSOR,
SCULK_CATALYST,
SCULK_SHRIEKER,
CHISELED_BOOKSHELF,
SUSPICIOUS_SAND,
BRUSHABLE_BLOCK,
DECORATED_POT;

private static final BlockEntityType[] VALUES = values();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public enum ParticleType {
FIREWORK,
FISHING,
FLAME,
DRIPPING_CHERRY_LEAVES,
FALLING_CHERRY_LEAVES,
LANDING_CHERRY_LEAVES,
CHERRY_LEAVES,
SCULK_SOUL,
SCULK_CHARGE,
SCULK_CHARGE_POP,
Expand Down Expand Up @@ -96,7 +94,8 @@ public enum ParticleType {
WAX_OFF,
ELECTRIC_SPARK,
SCRAPE,
SHRIEK;
SHRIEK,
EGG_CRACK;

private static final ParticleType[] VALUES = values();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public enum BuiltinSound implements Sound {
BLOCK_AMETHYST_BLOCK_FALL("block.amethyst_block.fall"),
BLOCK_AMETHYST_BLOCK_HIT("block.amethyst_block.hit"),
BLOCK_AMETHYST_BLOCK_PLACE("block.amethyst_block.place"),
BLOCK_AMETHYST_BLOCK_RESONATE("block.amethyst_block.resonate"),
BLOCK_AMETHYST_BLOCK_STEP("block.amethyst_block.step"),
BLOCK_AMETHYST_CLUSTER_BREAK("block.amethyst_cluster.break"),
BLOCK_AMETHYST_CLUSTER_FALL("block.amethyst_cluster.fall"),
Expand Down Expand Up @@ -173,8 +174,11 @@ public enum BuiltinSound implements Sound {
ITEM_BOTTLE_FILL("item.bottle.fill"),
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"),
ITEM_BRUSH_BRUSHING("item.brush.brushing"),
ITEM_BRUSH_BRUSH_SAND_COMPLETED("item.brush.brush_sand_completed"),
ITEM_BRUSH_BRUSHING_GENERIC("item.brush.brushing.generic"),
ITEM_BRUSH_BRUSHING_SAND("item.brush.brushing.sand"),
ITEM_BRUSH_BRUSHING_GRAVEL("item.brush.brushing.gravel"),
ITEM_BRUSH_BRUSHING_SAND_COMPLETE("item.brush.brushing.sand.complete"),
ITEM_BRUSH_BRUSHING_GRAVEL_COMPLETE("item.brush.brushing.gravel.complete"),
BLOCK_BUBBLE_COLUMN_BUBBLE_POP("block.bubble_column.bubble_pop"),
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"),
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"),
Expand Down Expand Up @@ -485,6 +489,11 @@ public enum BuiltinSound implements Sound {
BLOCK_SUSPICIOUS_SAND_PLACE("block.suspicious_sand.place"),
BLOCK_SUSPICIOUS_SAND_HIT("block.suspicious_sand.hit"),
BLOCK_SUSPICIOUS_SAND_FALL("block.suspicious_sand.fall"),
BLOCK_SUSPICIOUS_GRAVEL_BREAK("block.suspicious_gravel.break"),
BLOCK_SUSPICIOUS_GRAVEL_STEP("block.suspicious_gravel.step"),
BLOCK_SUSPICIOUS_GRAVEL_PLACE("block.suspicious_gravel.place"),
BLOCK_SUSPICIOUS_GRAVEL_HIT("block.suspicious_gravel.hit"),
BLOCK_SUSPICIOUS_GRAVEL_FALL("block.suspicious_gravel.fall"),
BLOCK_FROGLIGHT_BREAK("block.froglight.break"),
BLOCK_FROGLIGHT_FALL("block.froglight.fall"),
BLOCK_FROGLIGHT_HIT("block.froglight.hit"),
Expand Down Expand Up @@ -799,6 +808,7 @@ public enum BuiltinSound implements Sound {
MUSIC_DISC_WAIT("music_disc.wait"),
MUSIC_DISC_WARD("music_disc.ward"),
MUSIC_DISC_OTHERSIDE("music_disc.otherside"),
MUSIC_DISC_RELIC("music_disc.relic"),
MUSIC_DRAGON("music.dragon"),
MUSIC_END("music.end"),
MUSIC_GAME("music.game"),
Expand All @@ -811,7 +821,7 @@ public enum BuiltinSound implements Sound {
MUSIC_OVERWORLD_JAGGED_PEAKS("music.overworld.jagged_peaks"),
MUSIC_OVERWORLD_LUSH_CAVES("music.overworld.lush_caves"),
MUSIC_OVERWORLD_SWAMP("music.overworld.swamp"),
MUSIC_OVERWORLD_JUNGLE_AND_FOREST("music.overworld.jungle_and_forest"),
MUSIC_OVERWORLD_FOREST("music.overworld.forest"),
MUSIC_OVERWORLD_OLD_GROWTH_TAIGA("music.overworld.old_growth_taiga"),
MUSIC_OVERWORLD_MEADOW("music.overworld.meadow"),
MUSIC_OVERWORLD_CHERRY_GROVE("music.overworld.cherry_grove"),
Expand All @@ -821,6 +831,12 @@ public enum BuiltinSound implements Sound {
MUSIC_NETHER_SOUL_SAND_VALLEY("music.nether.soul_sand_valley"),
MUSIC_OVERWORLD_STONY_PEAKS("music.overworld.stony_peaks"),
MUSIC_NETHER_WARPED_FOREST("music.nether.warped_forest"),
MUSIC_OVERWORLD_FLOWER_FOREST("music.overworld.flower_forest"),
MUSIC_OVERWORLD_DESERT("music.overworld.desert"),
MUSIC_OVERWORLD_BADLANDS("music.overworld.badlands"),
MUSIC_OVERWORLD_JUNGLE("music.overworld.jungle"),
MUSIC_OVERWORLD_SPARSE_JUNGLE("music.overworld.sparse_jungle"),
MUSIC_OVERWORLD_BAMBOO_JUNGLE("music.overworld.bamboo_jungle"),
MUSIC_UNDER_WATER("music.under_water"),
BLOCK_NETHER_BRICKS_BREAK("block.nether_bricks.break"),
BLOCK_NETHER_BRICKS_STEP("block.nether_bricks.step"),
Expand Down Expand Up @@ -1229,6 +1245,9 @@ public enum BuiltinSound implements Sound {
ENTITY_SNIFFER_DIGGING("entity.sniffer.digging"),
ENTITY_SNIFFER_DIGGING_STOP("entity.sniffer.digging_stop"),
ENTITY_SNIFFER_HAPPY("entity.sniffer.happy"),
BLOCK_SNIFFER_EGG_PLOP("block.sniffer_egg.plop"),
BLOCK_SNIFFER_EGG_CRACK("block.sniffer_egg.crack"),
BLOCK_SNIFFER_EGG_HATCH("block.sniffer_egg.hatch"),
ENTITY_SNOWBALL_THROW("entity.snowball.throw"),
BLOCK_SNOW_BREAK("block.snow.break"),
BLOCK_SNOW_FALL("block.snow.fall"),
Expand Down Expand Up @@ -1381,6 +1400,7 @@ public enum BuiltinSound implements Sound {
ENTITY_WARDEN_SONIC_CHARGE("entity.warden.sonic_charge"),
ENTITY_WARDEN_STEP("entity.warden.step"),
ENTITY_WARDEN_TENDRIL_CLICKS("entity.warden.tendril_clicks"),
BLOCK_SIGN_WAXED_INTERACT_FAIL("block.sign.waxed_interact_fail"),
BLOCK_WATER_AMBIENT("block.water.ambient"),
WEATHER_RAIN("weather.rain"),
WEATHER_RAIN_ABOVE("weather.rain.above"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public enum RecipeType {
SMOKING,
CAMPFIRE_COOKING,
STONECUTTING,
SMITHING,
SMITHING_TRANSFORM,
SMITHING_TRIM,
CRAFTING_DECORATED_POT;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ClientboundLoginPacket implements MinecraftPacket {
private final boolean debug;
private final boolean flat;
private final @Nullable GlobalPos lastDeathPos;
private final int portalCooldown;

public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.entityId = in.readInt();
Expand Down Expand Up @@ -62,6 +63,7 @@ public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IO
} else {
this.lastDeathPos = null;
}
this.portalCooldown = helper.readVarInt(in);
}

@Override
Expand Down Expand Up @@ -89,5 +91,6 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
if (this.lastDeathPos != null) {
helper.writeGlobalPos(out, this.lastDeathPos);
}
helper.writeVarInt(out, this.portalCooldown);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ClientboundRespawnPacket implements MinecraftPacket {
private final boolean keepMetadata;
private final boolean keepAttributes;
private final @Nullable GlobalPos lastDeathPos;
private final int portalCooldown;

public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.dimension = helper.readString(in);
Expand All @@ -42,6 +43,7 @@ public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.keepAttributes = (dataToKeep & KEEP_ATTRIBUTES) != 0;
this.keepMetadata = (dataToKeep & KEEP_ENTITY_DATA) != 0;
this.lastDeathPos = helper.readNullable(in, helper::readGlobalPos);
this.portalCooldown = helper.readVarInt(in);
}

@Override
Expand All @@ -62,5 +64,6 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
}
out.writeByte(dataToKeep);
helper.writeNullable(out, this.lastDeathPos, helper::writeGlobalPos);
helper.writeVarInt(out, this.portalCooldown);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public ClientboundUpdateAdvancementsPacket(ByteBuf in, MinecraftCodecHelper help
requirements.add(requirement);
}

this.advancements[i] = new Advancement(id, criteria, requirements, parentId, displayData);
boolean sendTelemetryEvent = in.readBoolean();

this.advancements[i] = new Advancement(id, criteria, requirements, parentId, displayData, sendTelemetryEvent);
}

this.removedAdvancements = new String[helper.readVarInt(in)];
Expand Down Expand Up @@ -175,6 +177,8 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
helper.writeString(out, criterion);
}
}

out.writeBoolean(advancement.isSendsTelemetryEvent());
}

helper.writeVarInt(out, this.removedAdvancements.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ public ClientboundUpdateRecipesPacket(ByteBuf in, MinecraftCodecHelper helper) t
data = new StoneCuttingRecipeData(group, ingredient, result);
break;
}
case SMITHING: {
Ingredient base = helper.readRecipeIngredient(in);
Ingredient addition = helper.readRecipeIngredient(in);
ItemStack result = helper.readItemStack(in);

data = new LegacyUpgradeRecipeData(base, addition, result);
break;
}
case SMITHING_TRANSFORM: {
Ingredient template = helper.readRecipeIngredient(in);
Ingredient base = helper.readRecipeIngredient(in);
Expand Down Expand Up @@ -177,14 +169,6 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
helper.writeItemStack(out, data.getResult());
break;
}
case SMITHING: {
LegacyUpgradeRecipeData data = (LegacyUpgradeRecipeData) recipe.getData();

helper.writeRecipeIngredient(out, data.getBase());
helper.writeRecipeIngredient(out, data.getAddition());
helper.writeItemStack(out, data.getResult());
break;
}
case SMITHING_TRANSFORM: {
SmithingTransformRecipeData data = (SmithingTransformRecipeData) recipe.getData();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@
@With
@AllArgsConstructor
public class ClientboundPlayerCombatEndPacket implements MinecraftPacket {
private final int killerId;
private final int duration;

public ClientboundPlayerCombatEndPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.duration = helper.readVarInt(in);
this.killerId = in.readInt();
}

@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writeVarInt(out, this.duration);
out.writeInt(this.killerId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@
@AllArgsConstructor
public class ClientboundPlayerCombatKillPacket implements MinecraftPacket {
private final int playerId;
private final int killerId;
private final Component message;

public ClientboundPlayerCombatKillPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.playerId = helper.readVarInt(in);
this.killerId = in.readInt();
this.message = helper.readComponent(in);
}

@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writeVarInt(out, this.playerId);
out.writeInt(this.killerId);
helper.writeComponent(out, this.message);
}
}
Loading

0 comments on commit caa35c7

Please sign in to comment.