From 1205c3696520a4e2e440c9302b09e3b745d87fa5 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Wed, 3 Jun 2020 20:33:08 -0500 Subject: [PATCH] Add support for 20w22a --- pom.xml | 2 +- .../steveice10/mc/protocol/MinecraftConstants.java | 4 ++-- .../steveice10/mc/protocol/data/MagicValues.java | 14 ++++++++++++++ .../protocol/data/game/command/SuggestionType.java | 2 +- .../data/game/world/particle/ParticleType.java | 10 +++++++++- .../world/ClientGenerateStructuresPacket.java | 3 +++ .../packet/ingame/server/ServerJoinGamePacket.java | 13 +++++++++++++ .../packet/ingame/server/ServerRespawnPacket.java | 3 +++ .../mc/protocol/MinecraftProtocolTest.java | 2 +- 9 files changed, 47 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 3efb2af8..5c38e888 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.github.steveice10 mcprotocollib - 20w21a-SNAPSHOT + 20w22a-SNAPSHOT jar MCProtocolLib diff --git a/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java b/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java index 752a53fd..b466ff63 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java +++ b/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java @@ -2,8 +2,8 @@ package com.github.steveice10.mc.protocol; public class MinecraftConstants { // General Constants - public static final String GAME_VERSION = "20w21a"; - public static final int PROTOCOL_VERSION = 718; + public static final String GAME_VERSION = "20w22a"; + public static final int PROTOCOL_VERSION = 719; // General Key Constants public static final String PROFILE_KEY = "profile"; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index 3f206d3a..9eb94bc3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -645,6 +645,7 @@ public class MagicValues { register(UpdatedTileType.STRUCTURE_BLOCK, 7); register(UpdatedTileType.END_GATEWAY, 8); register(UpdatedTileType.SIGN, 9); + register(UpdatedTileType.SHULKER_BOX, 10); register(UpdatedTileType.BED, 11); register(UpdatedTileType.JIGSAW_BLOCK, 12); register(UpdatedTileType.CAMPFIRE, 13); @@ -835,6 +836,18 @@ public class MagicValues { register(ParticleType.DOLPHIN, 55); register(ParticleType.CAMPFIRE_COSY_SMOKE, 56); register(ParticleType.CAMPFIRE_SIGNAL_SMOKE, 57); + register(ParticleType.DRIPPING_HONEY, 58); + register(ParticleType.FALLING_HONEY, 59); + register(ParticleType.LANDING_HONEY, 60); + register(ParticleType.FALLING_NECTAR, 61); + register(ParticleType.ASH, 62); + register(ParticleType.CRIMSON_SPORE, 63); + register(ParticleType.WARPED_SPORE, 64); + register(ParticleType.DRIPPING_OBBSIDIAN_TEAR, 65); + register(ParticleType.FALLING_OBSIDIAN_TEAR, 66); + register(ParticleType.LANDING_OBSIDIAN_TEAR, 67); + register(ParticleType.REVERSE_PORTAL, 68); + register(ParticleType.WHITE_ASH, 69); register(NoteBlockValueType.HARP, 0); register(NoteBlockValueType.DOUBLE_BASS, 1); @@ -1141,6 +1154,7 @@ public class MagicValues { register(SuggestionType.ASK_SERVER, "minecraft:ask_server"); register(SuggestionType.ALL_RECIPES, "minecraft:all_recipes"); register(SuggestionType.AVAILABLE_SOUNDS, "minecraft:available_sounds"); + register(SuggestionType.AVAILABLE_BIOMES, "minecraft:available_biomes"); register(SuggestionType.SUMMONABLE_ENTITIES, "minecraft:summonable_entities"); register(StringProperties.SINGLE_WORD, 0); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java index 3ebc227a..fd68daaa 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java @@ -3,7 +3,7 @@ package com.github.steveice10.mc.protocol.data.game.command; public enum SuggestionType { ASK_SERVER, ALL_RECIPES, - AVAILABLE_BIOMES, AVAILABLE_SOUNDS, + AVAILABLE_BIOMES, SUMMONABLE_ENTITIES; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java index f1f0dda2..954eb2db 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java @@ -62,5 +62,13 @@ public enum ParticleType { DRIPPING_HONEY, FALLING_HONEY, LANDING_HONEY, - FALLING_NECTAR + FALLING_NECTAR, + ASH, + CRIMSON_SPORE, + WARPED_SPORE, + DRIPPING_OBBSIDIAN_TEAR, + FALLING_OBSIDIAN_TEAR, + LANDING_OBSIDIAN_TEAR, + REVERSE_PORTAL, + WHITE_ASH, } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/world/ClientGenerateStructuresPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/world/ClientGenerateStructuresPacket.java index 68e98f5f..cc372e85 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/world/ClientGenerateStructuresPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/world/ClientGenerateStructuresPacket.java @@ -20,17 +20,20 @@ import java.io.IOException; public class ClientGenerateStructuresPacket implements Packet { private @NonNull Position position; private int levels; + private boolean keepJigsaws; @Override public void read(NetInput in) throws IOException { this.position = Position.read(in); this.levels = in.readVarInt(); + this.keepJigsaws = in.readBoolean(); } @Override public void write(NetOutput out) throws IOException { Position.write(out, this.position); out.writeVarInt(this.levels); + out.writeBoolean(this.keepJigsaws); } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java index 98a51eed..39b267de 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java @@ -27,8 +27,11 @@ public class ServerJoinGamePacket implements Packet { private int entityId; private boolean hardcore; private @NonNull GameMode gameMode; + private int worldCount; + private String[] worldNames; private @NonNull CompoundTag dimensionCodec; private @NonNull String dimension; + private String worldName; private long hashedSeed; private int maxPlayers; private int viewDistance; @@ -44,8 +47,13 @@ public class ServerJoinGamePacket implements Packet { int gameMode = in.readUnsignedByte(); this.hardcore = (gameMode & GAMEMODE_FLAG_HARDCORE) != 0; this.gameMode = MagicValues.key(GameMode.class, gameMode & GAMEMODE_MASK); + this.worldCount = in.readVarInt(); + for (int i = 0; i < this.worldCount; i++) { + in.readString(); + } this.dimensionCodec = NBT.read(in); this.dimension = in.readString(); + this.worldName = in.readString(); this.hashedSeed = in.readLong(); this.maxPlayers = in.readUnsignedByte(); this.viewDistance = in.readVarInt(); @@ -65,8 +73,13 @@ public class ServerJoinGamePacket implements Packet { } out.writeByte(gameMode); + out.writeVarInt(this.worldCount); + for (String worldName : this.worldNames) { + out.writeString(worldName); + } NBT.write(out, this.dimensionCodec); out.writeString(this.dimension); + out.writeString(this.worldName); out.writeLong(this.hashedSeed); out.writeByte(this.maxPlayers); out.writeVarInt(this.viewDistance); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java index 9c10d269..1d234ed6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java @@ -20,6 +20,7 @@ import java.io.IOException; @AllArgsConstructor public class ServerRespawnPacket implements Packet { private String dimension; + private String worldName; private long hashedSeed; private @NonNull GameMode gamemode; private boolean debug; @@ -29,6 +30,7 @@ public class ServerRespawnPacket implements Packet { @Override public void read(NetInput in) throws IOException { this.dimension = in.readString(); + this.worldName = in.readString(); this.hashedSeed = in.readLong(); this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte()); this.debug = in.readBoolean(); @@ -39,6 +41,7 @@ public class ServerRespawnPacket implements Packet { @Override public void write(NetOutput out) throws IOException { out.writeString(this.dimension); + out.writeString(this.worldName); out.writeLong(this.hashedSeed); out.writeByte(MagicValues.value(Integer.class, this.gamemode)); out.writeBoolean(this.debug); diff --git a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java index 97392696..7c846eb5 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -47,7 +47,7 @@ public class MinecraftProtocolTest { new TextMessage("Hello world!"), null ); - private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, getDimensionTag(), "minecraft:overworld", 100, 0, 16, false, false, false, false); + private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "minecraft:overworld", "minecraft:world", 100, 0, 16, false, false, false, false); private static Server server;