Skip to content

Commit caa35c7

Browse files
authored
Merge pull request #734 from GeyserMC/feature/1.20
1.20 support
2 parents d2803b7 + 4e72a93 commit caa35c7

28 files changed

+85
-97
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- master
7-
- feature/math-2.0 #TEMPOARY
7+
- feature/1.20 #TEMPOARY
88

99
jobs:
1010
build:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.steveice10</groupId>
77
<artifactId>mcprotocollib</artifactId>
8-
<version>1.19.4-2-SNAPSHOT</version>
8+
<version>1.20-1</version>
99
<packaging>jar</packaging>
1010

1111
<name>MCProtocolLib</name>

src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ public class MinecraftCodec {
199199
}
200200

201201
public static final PacketCodec CODEC = PacketCodec.builder()
202-
.protocolVersion(762)
202+
.protocolVersion(763)
203203
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
204-
.minecraftVersion("1.19.4")
204+
.minecraftVersion("1.20")
205205
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
206206
.registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new)
207207
)

src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,6 @@ public void writeBlockEntityType(ByteBuf buf, BlockEntityType type) {
578578
}
579579

580580
public LightUpdateData readLightUpdateData(ByteBuf buf) {
581-
boolean trustEdges = buf.readBoolean();
582-
583581
BitSet skyYMask = BitSet.valueOf(this.readLongArray(buf));
584582
BitSet blockYMask = BitSet.valueOf(this.readLongArray(buf));
585583
BitSet emptySkyYMask = BitSet.valueOf(this.readLongArray(buf));
@@ -597,12 +595,10 @@ public LightUpdateData readLightUpdateData(ByteBuf buf) {
597595
blockUpdates.add(this.readByteArray(buf));
598596
}
599597

600-
return new LightUpdateData(skyYMask, blockYMask, emptySkyYMask, emptyBlockYMask, skyUpdates, blockUpdates, trustEdges);
598+
return new LightUpdateData(skyYMask, blockYMask, emptySkyYMask, emptyBlockYMask, skyUpdates, blockUpdates);
601599
}
602600

603601
public void writeLightUpdateData(ByteBuf buf, LightUpdateData data) {
604-
buf.writeBoolean(data.isTrustEdges());
605-
606602
writeBitSet(buf, data.getSkyYMask());
607603
writeBitSet(buf, data.getBlockYMask());
608604
writeBitSet(buf, data.getEmptySkyYMask());

src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ public class Advancement {
1616
private final @NonNull List<List<String>> requirements;
1717
private final String parentId;
1818
private final DisplayData displayData;
19+
private final boolean sendsTelemetryEvent;
1920

20-
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements) {
21-
this(id, criteria, requirements, null, null);
21+
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, boolean sendsTelemetryEvent) {
22+
this(id, criteria, requirements, null, null, sendsTelemetryEvent);
2223
}
2324

24-
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, String parentId) {
25-
this(id, criteria, requirements, parentId, null);
25+
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, String parentId, boolean sendsTelemetryEvent) {
26+
this(id, criteria, requirements, parentId, null, sendsTelemetryEvent);
2627
}
2728

28-
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, DisplayData displayData) {
29-
this(id, criteria, requirements, null, displayData);
29+
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, DisplayData displayData, boolean sendsTelemetryEvent) {
30+
this(id, criteria, requirements, null, displayData, sendsTelemetryEvent);
3031
}
3132

3233
@Data

src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/ContainerType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public enum ContainerType {
2121
LOOM,
2222
MERCHANT,
2323
SHULKER_BOX,
24-
LEGACY_SMITHING,
2524
SMITHING,
2625
SMOKER,
2726
CARTOGRAPHY,

src/main/java/com/github/steveice10/mc/protocol/data/game/level/LightUpdateData.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@ public class LightUpdateData {
2020
private final @NonNull BitSet emptyBlockYMask;
2121
private final @NonNull List<byte[]> skyUpdates;
2222
private final @NonNull List<byte[]> blockUpdates;
23-
private final boolean trustEdges;
2423

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

2928
private LightUpdateData(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
30-
this.trustEdges = in.readBoolean();
31-
3229
this.skyYMask = BitSet.valueOf(helper.readLongArray(in));
3330
this.blockYMask = BitSet.valueOf(helper.readLongArray(in));
3431
this.emptySkyYMask = BitSet.valueOf(helper.readLongArray(in));
@@ -52,8 +49,6 @@ public static void write(ByteBuf out, MinecraftCodecHelper helper, LightUpdateDa
5249
}
5350

5451
private void write(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
55-
out.writeBoolean(this.trustEdges);
56-
5752
writeBitSet(out, helper, this.skyYMask);
5853
writeBitSet(out, helper, this.blockYMask);
5954
writeBitSet(out, helper, this.emptySkyYMask);

src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ public enum BlockEntityType {
3636
CAMPFIRE,
3737
BEEHIVE,
3838
SCULK_SENSOR,
39+
CALIBRATED_SCULK_SENSOR,
3940
SCULK_CATALYST,
4041
SCULK_SHRIEKER,
4142
CHISELED_BOOKSHELF,
42-
SUSPICIOUS_SAND,
43+
BRUSHABLE_BLOCK,
4344
DECORATED_POT;
4445

4546
private static final BlockEntityType[] VALUES = values();

src/main/java/com/github/steveice10/mc/protocol/data/game/level/particle/ParticleType.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public enum ParticleType {
3030
FIREWORK,
3131
FISHING,
3232
FLAME,
33-
DRIPPING_CHERRY_LEAVES,
34-
FALLING_CHERRY_LEAVES,
35-
LANDING_CHERRY_LEAVES,
33+
CHERRY_LEAVES,
3634
SCULK_SOUL,
3735
SCULK_CHARGE,
3836
SCULK_CHARGE_POP,
@@ -96,7 +94,8 @@ public enum ParticleType {
9694
WAX_OFF,
9795
ELECTRIC_SPARK,
9896
SCRAPE,
99-
SHRIEK;
97+
SHRIEK,
98+
EGG_CRACK;
10099

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

src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/BuiltinSound.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public enum BuiltinSound implements Sound {
4141
BLOCK_AMETHYST_BLOCK_FALL("block.amethyst_block.fall"),
4242
BLOCK_AMETHYST_BLOCK_HIT("block.amethyst_block.hit"),
4343
BLOCK_AMETHYST_BLOCK_PLACE("block.amethyst_block.place"),
44+
BLOCK_AMETHYST_BLOCK_RESONATE("block.amethyst_block.resonate"),
4445
BLOCK_AMETHYST_BLOCK_STEP("block.amethyst_block.step"),
4546
BLOCK_AMETHYST_CLUSTER_BREAK("block.amethyst_cluster.break"),
4647
BLOCK_AMETHYST_CLUSTER_FALL("block.amethyst_cluster.fall"),
@@ -173,8 +174,11 @@ public enum BuiltinSound implements Sound {
173174
ITEM_BOTTLE_FILL("item.bottle.fill"),
174175
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
175176
BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"),
176-
ITEM_BRUSH_BRUSHING("item.brush.brushing"),
177-
ITEM_BRUSH_BRUSH_SAND_COMPLETED("item.brush.brush_sand_completed"),
177+
ITEM_BRUSH_BRUSHING_GENERIC("item.brush.brushing.generic"),
178+
ITEM_BRUSH_BRUSHING_SAND("item.brush.brushing.sand"),
179+
ITEM_BRUSH_BRUSHING_GRAVEL("item.brush.brushing.gravel"),
180+
ITEM_BRUSH_BRUSHING_SAND_COMPLETE("item.brush.brushing.sand.complete"),
181+
ITEM_BRUSH_BRUSHING_GRAVEL_COMPLETE("item.brush.brushing.gravel.complete"),
178182
BLOCK_BUBBLE_COLUMN_BUBBLE_POP("block.bubble_column.bubble_pop"),
179183
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"),
180184
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"),
@@ -485,6 +489,11 @@ public enum BuiltinSound implements Sound {
485489
BLOCK_SUSPICIOUS_SAND_PLACE("block.suspicious_sand.place"),
486490
BLOCK_SUSPICIOUS_SAND_HIT("block.suspicious_sand.hit"),
487491
BLOCK_SUSPICIOUS_SAND_FALL("block.suspicious_sand.fall"),
492+
BLOCK_SUSPICIOUS_GRAVEL_BREAK("block.suspicious_gravel.break"),
493+
BLOCK_SUSPICIOUS_GRAVEL_STEP("block.suspicious_gravel.step"),
494+
BLOCK_SUSPICIOUS_GRAVEL_PLACE("block.suspicious_gravel.place"),
495+
BLOCK_SUSPICIOUS_GRAVEL_HIT("block.suspicious_gravel.hit"),
496+
BLOCK_SUSPICIOUS_GRAVEL_FALL("block.suspicious_gravel.fall"),
488497
BLOCK_FROGLIGHT_BREAK("block.froglight.break"),
489498
BLOCK_FROGLIGHT_FALL("block.froglight.fall"),
490499
BLOCK_FROGLIGHT_HIT("block.froglight.hit"),
@@ -799,6 +808,7 @@ public enum BuiltinSound implements Sound {
799808
MUSIC_DISC_WAIT("music_disc.wait"),
800809
MUSIC_DISC_WARD("music_disc.ward"),
801810
MUSIC_DISC_OTHERSIDE("music_disc.otherside"),
811+
MUSIC_DISC_RELIC("music_disc.relic"),
802812
MUSIC_DRAGON("music.dragon"),
803813
MUSIC_END("music.end"),
804814
MUSIC_GAME("music.game"),
@@ -811,7 +821,7 @@ public enum BuiltinSound implements Sound {
811821
MUSIC_OVERWORLD_JAGGED_PEAKS("music.overworld.jagged_peaks"),
812822
MUSIC_OVERWORLD_LUSH_CAVES("music.overworld.lush_caves"),
813823
MUSIC_OVERWORLD_SWAMP("music.overworld.swamp"),
814-
MUSIC_OVERWORLD_JUNGLE_AND_FOREST("music.overworld.jungle_and_forest"),
824+
MUSIC_OVERWORLD_FOREST("music.overworld.forest"),
815825
MUSIC_OVERWORLD_OLD_GROWTH_TAIGA("music.overworld.old_growth_taiga"),
816826
MUSIC_OVERWORLD_MEADOW("music.overworld.meadow"),
817827
MUSIC_OVERWORLD_CHERRY_GROVE("music.overworld.cherry_grove"),
@@ -821,6 +831,12 @@ public enum BuiltinSound implements Sound {
821831
MUSIC_NETHER_SOUL_SAND_VALLEY("music.nether.soul_sand_valley"),
822832
MUSIC_OVERWORLD_STONY_PEAKS("music.overworld.stony_peaks"),
823833
MUSIC_NETHER_WARPED_FOREST("music.nether.warped_forest"),
834+
MUSIC_OVERWORLD_FLOWER_FOREST("music.overworld.flower_forest"),
835+
MUSIC_OVERWORLD_DESERT("music.overworld.desert"),
836+
MUSIC_OVERWORLD_BADLANDS("music.overworld.badlands"),
837+
MUSIC_OVERWORLD_JUNGLE("music.overworld.jungle"),
838+
MUSIC_OVERWORLD_SPARSE_JUNGLE("music.overworld.sparse_jungle"),
839+
MUSIC_OVERWORLD_BAMBOO_JUNGLE("music.overworld.bamboo_jungle"),
824840
MUSIC_UNDER_WATER("music.under_water"),
825841
BLOCK_NETHER_BRICKS_BREAK("block.nether_bricks.break"),
826842
BLOCK_NETHER_BRICKS_STEP("block.nether_bricks.step"),
@@ -1229,6 +1245,9 @@ public enum BuiltinSound implements Sound {
12291245
ENTITY_SNIFFER_DIGGING("entity.sniffer.digging"),
12301246
ENTITY_SNIFFER_DIGGING_STOP("entity.sniffer.digging_stop"),
12311247
ENTITY_SNIFFER_HAPPY("entity.sniffer.happy"),
1248+
BLOCK_SNIFFER_EGG_PLOP("block.sniffer_egg.plop"),
1249+
BLOCK_SNIFFER_EGG_CRACK("block.sniffer_egg.crack"),
1250+
BLOCK_SNIFFER_EGG_HATCH("block.sniffer_egg.hatch"),
12321251
ENTITY_SNOWBALL_THROW("entity.snowball.throw"),
12331252
BLOCK_SNOW_BREAK("block.snow.break"),
12341253
BLOCK_SNOW_FALL("block.snow.fall"),
@@ -1381,6 +1400,7 @@ public enum BuiltinSound implements Sound {
13811400
ENTITY_WARDEN_SONIC_CHARGE("entity.warden.sonic_charge"),
13821401
ENTITY_WARDEN_STEP("entity.warden.step"),
13831402
ENTITY_WARDEN_TENDRIL_CLICKS("entity.warden.tendril_clicks"),
1403+
BLOCK_SIGN_WAXED_INTERACT_FAIL("block.sign.waxed_interact_fail"),
13841404
BLOCK_WATER_AMBIENT("block.water.ambient"),
13851405
WEATHER_RAIN("weather.rain"),
13861406
WEATHER_RAIN_ABOVE("weather.rain.above"),

src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/RecipeType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public enum RecipeType {
2727
SMOKING,
2828
CAMPFIRE_COOKING,
2929
STONECUTTING,
30-
SMITHING,
3130
SMITHING_TRANSFORM,
3231
SMITHING_TRIM,
3332
CRAFTING_DECORATED_POT;

src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/LegacyUpgradeRecipeData.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class ClientboundLoginPacket implements MinecraftPacket {
3535
private final boolean debug;
3636
private final boolean flat;
3737
private final @Nullable GlobalPos lastDeathPos;
38+
private final int portalCooldown;
3839

3940
public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
4041
this.entityId = in.readInt();
@@ -62,6 +63,7 @@ public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IO
6263
} else {
6364
this.lastDeathPos = null;
6465
}
66+
this.portalCooldown = helper.readVarInt(in);
6567
}
6668

6769
@Override
@@ -89,5 +91,6 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
8991
if (this.lastDeathPos != null) {
9092
helper.writeGlobalPos(out, this.lastDeathPos);
9193
}
94+
helper.writeVarInt(out, this.portalCooldown);
9295
}
9396
}

src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class ClientboundRespawnPacket implements MinecraftPacket {
2929
private final boolean keepMetadata;
3030
private final boolean keepAttributes;
3131
private final @Nullable GlobalPos lastDeathPos;
32+
private final int portalCooldown;
3233

3334
public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) {
3435
this.dimension = helper.readString(in);
@@ -42,6 +43,7 @@ public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) {
4243
this.keepAttributes = (dataToKeep & KEEP_ATTRIBUTES) != 0;
4344
this.keepMetadata = (dataToKeep & KEEP_ENTITY_DATA) != 0;
4445
this.lastDeathPos = helper.readNullable(in, helper::readGlobalPos);
46+
this.portalCooldown = helper.readVarInt(in);
4547
}
4648

4749
@Override
@@ -62,5 +64,6 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
6264
}
6365
out.writeByte(dataToKeep);
6466
helper.writeNullable(out, this.lastDeathPos, helper::writeGlobalPos);
67+
helper.writeVarInt(out, this.portalCooldown);
6568
}
6669
}

src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateAdvancementsPacket.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public ClientboundUpdateAdvancementsPacket(ByteBuf in, MinecraftCodecHelper help
9090
requirements.add(requirement);
9191
}
9292

93-
this.advancements[i] = new Advancement(id, criteria, requirements, parentId, displayData);
93+
boolean sendTelemetryEvent = in.readBoolean();
94+
95+
this.advancements[i] = new Advancement(id, criteria, requirements, parentId, displayData, sendTelemetryEvent);
9496
}
9597

9698
this.removedAdvancements = new String[helper.readVarInt(in)];
@@ -175,6 +177,8 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
175177
helper.writeString(out, criterion);
176178
}
177179
}
180+
181+
out.writeBoolean(advancement.isSendsTelemetryEvent());
178182
}
179183

180184
helper.writeVarInt(out, this.removedAdvancements.length);

src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateRecipesPacket.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ public ClientboundUpdateRecipesPacket(ByteBuf in, MinecraftCodecHelper helper) t
8080
data = new StoneCuttingRecipeData(group, ingredient, result);
8181
break;
8282
}
83-
case SMITHING: {
84-
Ingredient base = helper.readRecipeIngredient(in);
85-
Ingredient addition = helper.readRecipeIngredient(in);
86-
ItemStack result = helper.readItemStack(in);
87-
88-
data = new LegacyUpgradeRecipeData(base, addition, result);
89-
break;
90-
}
9183
case SMITHING_TRANSFORM: {
9284
Ingredient template = helper.readRecipeIngredient(in);
9385
Ingredient base = helper.readRecipeIngredient(in);
@@ -177,14 +169,6 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
177169
helper.writeItemStack(out, data.getResult());
178170
break;
179171
}
180-
case SMITHING: {
181-
LegacyUpgradeRecipeData data = (LegacyUpgradeRecipeData) recipe.getData();
182-
183-
helper.writeRecipeIngredient(out, data.getBase());
184-
helper.writeRecipeIngredient(out, data.getAddition());
185-
helper.writeItemStack(out, data.getResult());
186-
break;
187-
}
188172
case SMITHING_TRANSFORM: {
189173
SmithingTransformRecipeData data = (SmithingTransformRecipeData) recipe.getData();
190174

src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEndPacket.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@
1313
@With
1414
@AllArgsConstructor
1515
public class ClientboundPlayerCombatEndPacket implements MinecraftPacket {
16-
private final int killerId;
1716
private final int duration;
1817

1918
public ClientboundPlayerCombatEndPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
2019
this.duration = helper.readVarInt(in);
21-
this.killerId = in.readInt();
2220
}
2321

2422
@Override
2523
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
2624
helper.writeVarInt(out, this.duration);
27-
out.writeInt(this.killerId);
2825
}
2926
}

src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatKillPacket.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@
1515
@AllArgsConstructor
1616
public class ClientboundPlayerCombatKillPacket implements MinecraftPacket {
1717
private final int playerId;
18-
private final int killerId;
1918
private final Component message;
2019

2120
public ClientboundPlayerCombatKillPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
2221
this.playerId = helper.readVarInt(in);
23-
this.killerId = in.readInt();
2422
this.message = helper.readComponent(in);
2523
}
2624

2725
@Override
2826
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
2927
helper.writeVarInt(out, this.playerId);
30-
out.writeInt(this.killerId);
3128
helper.writeComponent(out, this.message);
3229
}
3330
}

0 commit comments

Comments
 (0)