Merge pull request from GeyserMC/feature/1.20

1.20 support
This commit is contained in:
Redned 2023-06-07 09:05:48 -05:00 committed by GitHub
commit caa35c7be4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 85 additions and 97 deletions

View file

@ -4,7 +4,7 @@ on:
push: push:
branches: branches:
- master - master
- feature/math-2.0 #TEMPOARY - feature/1.20 #TEMPOARY
jobs: jobs:
build: build:

View file

@ -5,7 +5,7 @@
<groupId>com.github.steveice10</groupId> <groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId> <artifactId>mcprotocollib</artifactId>
<version>1.19.4-2-SNAPSHOT</version> <version>1.20-1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>MCProtocolLib</name> <name>MCProtocolLib</name>

View file

@ -199,9 +199,9 @@ public class MinecraftCodec {
} }
public static final PacketCodec CODEC = PacketCodec.builder() public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion(762) .protocolVersion(763)
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES)) .helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
.minecraftVersion("1.19.4") .minecraftVersion("1.20")
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder() .state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
.registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new) .registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new)
) )

View file

@ -578,8 +578,6 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
} }
public LightUpdateData readLightUpdateData(ByteBuf buf) { public LightUpdateData readLightUpdateData(ByteBuf buf) {
boolean trustEdges = buf.readBoolean();
BitSet skyYMask = BitSet.valueOf(this.readLongArray(buf)); BitSet skyYMask = BitSet.valueOf(this.readLongArray(buf));
BitSet blockYMask = BitSet.valueOf(this.readLongArray(buf)); BitSet blockYMask = BitSet.valueOf(this.readLongArray(buf));
BitSet emptySkyYMask = BitSet.valueOf(this.readLongArray(buf)); BitSet emptySkyYMask = BitSet.valueOf(this.readLongArray(buf));
@ -597,12 +595,10 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
blockUpdates.add(this.readByteArray(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) { public void writeLightUpdateData(ByteBuf buf, LightUpdateData data) {
buf.writeBoolean(data.isTrustEdges());
writeBitSet(buf, data.getSkyYMask()); writeBitSet(buf, data.getSkyYMask());
writeBitSet(buf, data.getBlockYMask()); writeBitSet(buf, data.getBlockYMask());
writeBitSet(buf, data.getEmptySkyYMask()); writeBitSet(buf, data.getEmptySkyYMask());

View file

@ -16,17 +16,18 @@ public class Advancement {
private final @NonNull List<List<String>> requirements; private final @NonNull List<List<String>> requirements;
private final String parentId; private final String parentId;
private final DisplayData displayData; private final DisplayData displayData;
private final boolean sendsTelemetryEvent;
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements) { public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, boolean sendsTelemetryEvent) {
this(id, criteria, requirements, null, null); this(id, criteria, requirements, null, null, sendsTelemetryEvent);
} }
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, String parentId) { public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, String parentId, boolean sendsTelemetryEvent) {
this(id, criteria, requirements, parentId, null); this(id, criteria, requirements, parentId, null, sendsTelemetryEvent);
} }
public Advancement(@NonNull String id, @NonNull List<String> criteria, @NonNull List<List<String>> requirements, DisplayData 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); this(id, criteria, requirements, null, displayData, sendsTelemetryEvent);
} }
@Data @Data

View file

@ -21,7 +21,6 @@ public enum ContainerType {
LOOM, LOOM,
MERCHANT, MERCHANT,
SHULKER_BOX, SHULKER_BOX,
LEGACY_SMITHING,
SMITHING, SMITHING,
SMOKER, SMOKER,
CARTOGRAPHY, CARTOGRAPHY,

View file

@ -20,15 +20,12 @@ public class LightUpdateData {
private final @NonNull BitSet emptyBlockYMask; private final @NonNull BitSet emptyBlockYMask;
private final @NonNull List<byte[]> skyUpdates; private final @NonNull List<byte[]> skyUpdates;
private final @NonNull List<byte[]> blockUpdates; private final @NonNull List<byte[]> blockUpdates;
private final boolean trustEdges;
public static LightUpdateData read(ByteBuf in, MinecraftCodecHelper helper) throws IOException { public static LightUpdateData read(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
return new LightUpdateData(in, helper); return new LightUpdateData(in, helper);
} }
private LightUpdateData(ByteBuf in, MinecraftCodecHelper helper) throws IOException { private LightUpdateData(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.trustEdges = in.readBoolean();
this.skyYMask = BitSet.valueOf(helper.readLongArray(in)); this.skyYMask = BitSet.valueOf(helper.readLongArray(in));
this.blockYMask = BitSet.valueOf(helper.readLongArray(in)); this.blockYMask = BitSet.valueOf(helper.readLongArray(in));
this.emptySkyYMask = BitSet.valueOf(helper.readLongArray(in)); this.emptySkyYMask = BitSet.valueOf(helper.readLongArray(in));
@ -52,8 +49,6 @@ public class LightUpdateData {
} }
private void write(ByteBuf out, MinecraftCodecHelper helper) throws IOException { private void write(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
out.writeBoolean(this.trustEdges);
writeBitSet(out, helper, this.skyYMask); writeBitSet(out, helper, this.skyYMask);
writeBitSet(out, helper, this.blockYMask); writeBitSet(out, helper, this.blockYMask);
writeBitSet(out, helper, this.emptySkyYMask); writeBitSet(out, helper, this.emptySkyYMask);

View file

@ -36,10 +36,11 @@ public enum BlockEntityType {
CAMPFIRE, CAMPFIRE,
BEEHIVE, BEEHIVE,
SCULK_SENSOR, SCULK_SENSOR,
CALIBRATED_SCULK_SENSOR,
SCULK_CATALYST, SCULK_CATALYST,
SCULK_SHRIEKER, SCULK_SHRIEKER,
CHISELED_BOOKSHELF, CHISELED_BOOKSHELF,
SUSPICIOUS_SAND, BRUSHABLE_BLOCK,
DECORATED_POT; DECORATED_POT;
private static final BlockEntityType[] VALUES = values(); private static final BlockEntityType[] VALUES = values();

View file

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

View file

@ -41,6 +41,7 @@ public enum BuiltinSound implements Sound {
BLOCK_AMETHYST_BLOCK_FALL("block.amethyst_block.fall"), BLOCK_AMETHYST_BLOCK_FALL("block.amethyst_block.fall"),
BLOCK_AMETHYST_BLOCK_HIT("block.amethyst_block.hit"), BLOCK_AMETHYST_BLOCK_HIT("block.amethyst_block.hit"),
BLOCK_AMETHYST_BLOCK_PLACE("block.amethyst_block.place"), 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_BLOCK_STEP("block.amethyst_block.step"),
BLOCK_AMETHYST_CLUSTER_BREAK("block.amethyst_cluster.break"), BLOCK_AMETHYST_CLUSTER_BREAK("block.amethyst_cluster.break"),
BLOCK_AMETHYST_CLUSTER_FALL("block.amethyst_cluster.fall"), BLOCK_AMETHYST_CLUSTER_FALL("block.amethyst_cluster.fall"),
@ -173,8 +174,11 @@ public enum BuiltinSound implements Sound {
ITEM_BOTTLE_FILL("item.bottle.fill"), ITEM_BOTTLE_FILL("item.bottle.fill"),
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"), ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"), BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"),
ITEM_BRUSH_BRUSHING("item.brush.brushing"), ITEM_BRUSH_BRUSHING_GENERIC("item.brush.brushing.generic"),
ITEM_BRUSH_BRUSH_SAND_COMPLETED("item.brush.brush_sand_completed"), 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_BUBBLE_POP("block.bubble_column.bubble_pop"),
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"), BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"),
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"), BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"),
@ -485,6 +489,11 @@ public enum BuiltinSound implements Sound {
BLOCK_SUSPICIOUS_SAND_PLACE("block.suspicious_sand.place"), BLOCK_SUSPICIOUS_SAND_PLACE("block.suspicious_sand.place"),
BLOCK_SUSPICIOUS_SAND_HIT("block.suspicious_sand.hit"), BLOCK_SUSPICIOUS_SAND_HIT("block.suspicious_sand.hit"),
BLOCK_SUSPICIOUS_SAND_FALL("block.suspicious_sand.fall"), 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_BREAK("block.froglight.break"),
BLOCK_FROGLIGHT_FALL("block.froglight.fall"), BLOCK_FROGLIGHT_FALL("block.froglight.fall"),
BLOCK_FROGLIGHT_HIT("block.froglight.hit"), BLOCK_FROGLIGHT_HIT("block.froglight.hit"),
@ -799,6 +808,7 @@ public enum BuiltinSound implements Sound {
MUSIC_DISC_WAIT("music_disc.wait"), MUSIC_DISC_WAIT("music_disc.wait"),
MUSIC_DISC_WARD("music_disc.ward"), MUSIC_DISC_WARD("music_disc.ward"),
MUSIC_DISC_OTHERSIDE("music_disc.otherside"), MUSIC_DISC_OTHERSIDE("music_disc.otherside"),
MUSIC_DISC_RELIC("music_disc.relic"),
MUSIC_DRAGON("music.dragon"), MUSIC_DRAGON("music.dragon"),
MUSIC_END("music.end"), MUSIC_END("music.end"),
MUSIC_GAME("music.game"), MUSIC_GAME("music.game"),
@ -811,7 +821,7 @@ public enum BuiltinSound implements Sound {
MUSIC_OVERWORLD_JAGGED_PEAKS("music.overworld.jagged_peaks"), MUSIC_OVERWORLD_JAGGED_PEAKS("music.overworld.jagged_peaks"),
MUSIC_OVERWORLD_LUSH_CAVES("music.overworld.lush_caves"), MUSIC_OVERWORLD_LUSH_CAVES("music.overworld.lush_caves"),
MUSIC_OVERWORLD_SWAMP("music.overworld.swamp"), 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_OLD_GROWTH_TAIGA("music.overworld.old_growth_taiga"),
MUSIC_OVERWORLD_MEADOW("music.overworld.meadow"), MUSIC_OVERWORLD_MEADOW("music.overworld.meadow"),
MUSIC_OVERWORLD_CHERRY_GROVE("music.overworld.cherry_grove"), MUSIC_OVERWORLD_CHERRY_GROVE("music.overworld.cherry_grove"),
@ -821,6 +831,12 @@ public enum BuiltinSound implements Sound {
MUSIC_NETHER_SOUL_SAND_VALLEY("music.nether.soul_sand_valley"), MUSIC_NETHER_SOUL_SAND_VALLEY("music.nether.soul_sand_valley"),
MUSIC_OVERWORLD_STONY_PEAKS("music.overworld.stony_peaks"), MUSIC_OVERWORLD_STONY_PEAKS("music.overworld.stony_peaks"),
MUSIC_NETHER_WARPED_FOREST("music.nether.warped_forest"), 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"), MUSIC_UNDER_WATER("music.under_water"),
BLOCK_NETHER_BRICKS_BREAK("block.nether_bricks.break"), BLOCK_NETHER_BRICKS_BREAK("block.nether_bricks.break"),
BLOCK_NETHER_BRICKS_STEP("block.nether_bricks.step"), BLOCK_NETHER_BRICKS_STEP("block.nether_bricks.step"),
@ -1229,6 +1245,9 @@ public enum BuiltinSound implements Sound {
ENTITY_SNIFFER_DIGGING("entity.sniffer.digging"), ENTITY_SNIFFER_DIGGING("entity.sniffer.digging"),
ENTITY_SNIFFER_DIGGING_STOP("entity.sniffer.digging_stop"), ENTITY_SNIFFER_DIGGING_STOP("entity.sniffer.digging_stop"),
ENTITY_SNIFFER_HAPPY("entity.sniffer.happy"), 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"), ENTITY_SNOWBALL_THROW("entity.snowball.throw"),
BLOCK_SNOW_BREAK("block.snow.break"), BLOCK_SNOW_BREAK("block.snow.break"),
BLOCK_SNOW_FALL("block.snow.fall"), BLOCK_SNOW_FALL("block.snow.fall"),
@ -1381,6 +1400,7 @@ public enum BuiltinSound implements Sound {
ENTITY_WARDEN_SONIC_CHARGE("entity.warden.sonic_charge"), ENTITY_WARDEN_SONIC_CHARGE("entity.warden.sonic_charge"),
ENTITY_WARDEN_STEP("entity.warden.step"), ENTITY_WARDEN_STEP("entity.warden.step"),
ENTITY_WARDEN_TENDRIL_CLICKS("entity.warden.tendril_clicks"), ENTITY_WARDEN_TENDRIL_CLICKS("entity.warden.tendril_clicks"),
BLOCK_SIGN_WAXED_INTERACT_FAIL("block.sign.waxed_interact_fail"),
BLOCK_WATER_AMBIENT("block.water.ambient"), BLOCK_WATER_AMBIENT("block.water.ambient"),
WEATHER_RAIN("weather.rain"), WEATHER_RAIN("weather.rain"),
WEATHER_RAIN_ABOVE("weather.rain.above"), WEATHER_RAIN_ABOVE("weather.rain.above"),

View file

@ -27,7 +27,6 @@ public enum RecipeType {
SMOKING, SMOKING,
CAMPFIRE_COOKING, CAMPFIRE_COOKING,
STONECUTTING, STONECUTTING,
SMITHING,
SMITHING_TRANSFORM, SMITHING_TRANSFORM,
SMITHING_TRIM, SMITHING_TRIM,
CRAFTING_DECORATED_POT; CRAFTING_DECORATED_POT;

View file

@ -1,15 +0,0 @@
package com.github.steveice10.mc.protocol.data.game.recipe.data;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
@Data
@AllArgsConstructor
public class LegacyUpgradeRecipeData implements RecipeData {
private final @NonNull Ingredient base;
private final @NonNull Ingredient addition;
private final ItemStack result;
}

View file

@ -35,6 +35,7 @@ public class ClientboundLoginPacket implements MinecraftPacket {
private final boolean debug; private final boolean debug;
private final boolean flat; private final boolean flat;
private final @Nullable GlobalPos lastDeathPos; private final @Nullable GlobalPos lastDeathPos;
private final int portalCooldown;
public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.entityId = in.readInt(); this.entityId = in.readInt();
@ -62,6 +63,7 @@ public class ClientboundLoginPacket implements MinecraftPacket {
} else { } else {
this.lastDeathPos = null; this.lastDeathPos = null;
} }
this.portalCooldown = helper.readVarInt(in);
} }
@Override @Override
@ -89,5 +91,6 @@ public class ClientboundLoginPacket implements MinecraftPacket {
if (this.lastDeathPos != null) { if (this.lastDeathPos != null) {
helper.writeGlobalPos(out, this.lastDeathPos); helper.writeGlobalPos(out, this.lastDeathPos);
} }
helper.writeVarInt(out, this.portalCooldown);
} }
} }

View file

@ -29,6 +29,7 @@ public class ClientboundRespawnPacket implements MinecraftPacket {
private final boolean keepMetadata; private final boolean keepMetadata;
private final boolean keepAttributes; private final boolean keepAttributes;
private final @Nullable GlobalPos lastDeathPos; private final @Nullable GlobalPos lastDeathPos;
private final int portalCooldown;
public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) { public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.dimension = helper.readString(in); this.dimension = helper.readString(in);
@ -42,6 +43,7 @@ public class ClientboundRespawnPacket implements MinecraftPacket {
this.keepAttributes = (dataToKeep & KEEP_ATTRIBUTES) != 0; this.keepAttributes = (dataToKeep & KEEP_ATTRIBUTES) != 0;
this.keepMetadata = (dataToKeep & KEEP_ENTITY_DATA) != 0; this.keepMetadata = (dataToKeep & KEEP_ENTITY_DATA) != 0;
this.lastDeathPos = helper.readNullable(in, helper::readGlobalPos); this.lastDeathPos = helper.readNullable(in, helper::readGlobalPos);
this.portalCooldown = helper.readVarInt(in);
} }
@Override @Override
@ -62,5 +64,6 @@ public class ClientboundRespawnPacket implements MinecraftPacket {
} }
out.writeByte(dataToKeep); out.writeByte(dataToKeep);
helper.writeNullable(out, this.lastDeathPos, helper::writeGlobalPos); helper.writeNullable(out, this.lastDeathPos, helper::writeGlobalPos);
helper.writeVarInt(out, this.portalCooldown);
} }
} }

View file

@ -90,7 +90,9 @@ public class ClientboundUpdateAdvancementsPacket implements MinecraftPacket {
requirements.add(requirement); 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)]; this.removedAdvancements = new String[helper.readVarInt(in)];
@ -175,6 +177,8 @@ public class ClientboundUpdateAdvancementsPacket implements MinecraftPacket {
helper.writeString(out, criterion); helper.writeString(out, criterion);
} }
} }
out.writeBoolean(advancement.isSendsTelemetryEvent());
} }
helper.writeVarInt(out, this.removedAdvancements.length); helper.writeVarInt(out, this.removedAdvancements.length);

View file

@ -80,14 +80,6 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
data = new StoneCuttingRecipeData(group, ingredient, result); data = new StoneCuttingRecipeData(group, ingredient, result);
break; 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: { case SMITHING_TRANSFORM: {
Ingredient template = helper.readRecipeIngredient(in); Ingredient template = helper.readRecipeIngredient(in);
Ingredient base = helper.readRecipeIngredient(in); Ingredient base = helper.readRecipeIngredient(in);
@ -177,14 +169,6 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
helper.writeItemStack(out, data.getResult()); helper.writeItemStack(out, data.getResult());
break; 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: { case SMITHING_TRANSFORM: {
SmithingTransformRecipeData data = (SmithingTransformRecipeData) recipe.getData(); SmithingTransformRecipeData data = (SmithingTransformRecipeData) recipe.getData();

View file

@ -13,17 +13,14 @@ import java.io.IOException;
@With @With
@AllArgsConstructor @AllArgsConstructor
public class ClientboundPlayerCombatEndPacket implements MinecraftPacket { public class ClientboundPlayerCombatEndPacket implements MinecraftPacket {
private final int killerId;
private final int duration; private final int duration;
public ClientboundPlayerCombatEndPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { public ClientboundPlayerCombatEndPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.duration = helper.readVarInt(in); this.duration = helper.readVarInt(in);
this.killerId = in.readInt();
} }
@Override @Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writeVarInt(out, this.duration); helper.writeVarInt(out, this.duration);
out.writeInt(this.killerId);
} }
} }

View file

@ -15,19 +15,16 @@ import java.io.IOException;
@AllArgsConstructor @AllArgsConstructor
public class ClientboundPlayerCombatKillPacket implements MinecraftPacket { public class ClientboundPlayerCombatKillPacket implements MinecraftPacket {
private final int playerId; private final int playerId;
private final int killerId;
private final Component message; private final Component message;
public ClientboundPlayerCombatKillPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { public ClientboundPlayerCombatKillPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.playerId = helper.readVarInt(in); this.playerId = helper.readVarInt(in);
this.killerId = in.readInt();
this.message = helper.readComponent(in); this.message = helper.readComponent(in);
} }
@Override @Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writeVarInt(out, this.playerId); helper.writeVarInt(out, this.playerId);
out.writeInt(this.killerId);
helper.writeComponent(out, this.message); helper.writeComponent(out, this.message);
} }
} }

View file

@ -16,17 +16,17 @@ import org.cloudburstmc.math.vector.Vector3i;
@AllArgsConstructor @AllArgsConstructor
public class ClientboundBlockEventPacket implements MinecraftPacket { public class ClientboundBlockEventPacket implements MinecraftPacket {
// Do we really want these hardcoded values? // Do we really want these hardcoded values?
private static final int NOTE_BLOCK = 101; private static final int NOTE_BLOCK = 102;
private static final int STICKY_PISTON = 120; private static final int STICKY_PISTON = 121;
private static final int PISTON = 127; private static final int PISTON = 128;
private static final int MOB_SPAWNER = 174; private static final int MOB_SPAWNER = 175;
private static final int CHEST = 176; private static final int CHEST = 177;
private static final int ENDER_CHEST = 343; private static final int ENDER_CHEST = 344;
private static final int TRAPPED_CHEST = 410; private static final int TRAPPED_CHEST = 411;
private static final int END_GATEWAY = 600; private static final int END_GATEWAY = 603;
private static final int SHULKER_BOX_LOWER = 610; private static final int SHULKER_BOX_LOWER = 613;
private static final int SHULKER_BOX_HIGHER = 626; private static final int SHULKER_BOX_HIGHER = 629;
private static final int BELL = 779; private static final int BELL = 783;
private final @NonNull Vector3i position; private final @NonNull Vector3i position;
private final @NonNull BlockValueType type; private final @NonNull BlockValueType type;

View file

@ -24,7 +24,7 @@ public class ClientboundLightUpdatePacket implements MinecraftPacket {
public ClientboundLightUpdatePacket(int x, int z, @NonNull BitSet skyYMask, @NonNull BitSet blockYMask, public ClientboundLightUpdatePacket(int x, int z, @NonNull BitSet skyYMask, @NonNull BitSet blockYMask,
@NonNull BitSet emptySkyYMask, @NonNull BitSet emptyBlockYMask, @NonNull BitSet emptySkyYMask, @NonNull BitSet emptyBlockYMask,
@NonNull List<byte[]> skyUpdates, @NonNull List<byte[]> blockUpdates, boolean trustEdges) { @NonNull List<byte[]> skyUpdates, @NonNull List<byte[]> blockUpdates) {
for (byte[] content : skyUpdates) { for (byte[] content : skyUpdates) {
if (content.length != 2048) { if (content.length != 2048) {
throw new IllegalArgumentException("All arrays in skyUpdates must be length of 2048!"); throw new IllegalArgumentException("All arrays in skyUpdates must be length of 2048!");
@ -37,7 +37,7 @@ public class ClientboundLightUpdatePacket implements MinecraftPacket {
} }
this.x = x; this.x = x;
this.z = z; this.z = z;
this.lightData = new LightUpdateData(skyYMask, blockYMask, emptySkyYMask, emptyBlockYMask, skyUpdates, blockUpdates, trustEdges); this.lightData = new LightUpdateData(skyYMask, blockYMask, emptySkyYMask, emptyBlockYMask, skyUpdates, blockUpdates);
} }
public ClientboundLightUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { public ClientboundLightUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {

View file

@ -16,13 +16,16 @@ import java.io.IOException;
@AllArgsConstructor @AllArgsConstructor
public class ClientboundOpenSignEditorPacket implements MinecraftPacket { public class ClientboundOpenSignEditorPacket implements MinecraftPacket {
private final @NonNull Vector3i position; private final @NonNull Vector3i position;
private final boolean isFrontText;
public ClientboundOpenSignEditorPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { public ClientboundOpenSignEditorPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.position = helper.readPosition(in); this.position = helper.readPosition(in);
this.isFrontText = in.readBoolean();
} }
@Override @Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writePosition(out, this.position); helper.writePosition(out, this.position);
out.writeBoolean(this.isFrontText);
} }
} }

View file

@ -17,13 +17,12 @@ public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket {
private final int chunkX; private final int chunkX;
private final int chunkY; private final int chunkY;
private final int chunkZ; private final int chunkZ;
private final boolean ignoreOldLight;
/** /**
* The server sends the record position in terms of the local chunk coordinate but it is stored here in terms of global coordinates. * The server sends the record position in terms of the local chunk coordinate but it is stored here in terms of global coordinates.
*/ */
private final @NonNull BlockChangeEntry[] entries; private final @NonNull BlockChangeEntry[] entries;
public ClientboundSectionBlocksUpdatePacket(int chunkX, int chunkY, int chunkZ, boolean ignoreOldLight, BlockChangeEntry... entries) { public ClientboundSectionBlocksUpdatePacket(int chunkX, int chunkY, int chunkZ, BlockChangeEntry... entries) {
if (entries == null || entries.length == 0) { if (entries == null || entries.length == 0) {
throw new IllegalArgumentException("Entries must contain at least 1 value."); throw new IllegalArgumentException("Entries must contain at least 1 value.");
} }
@ -31,7 +30,6 @@ public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket {
this.chunkX = chunkX; this.chunkX = chunkX;
this.chunkY = chunkY; this.chunkY = chunkY;
this.chunkZ = chunkZ; this.chunkZ = chunkZ;
this.ignoreOldLight = ignoreOldLight;
this.entries = entries; this.entries = entries;
} }
@ -40,7 +38,6 @@ public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket {
this.chunkX = (int) (chunkPosition >> 42); this.chunkX = (int) (chunkPosition >> 42);
this.chunkY = (int) (chunkPosition << 44 >> 44); this.chunkY = (int) (chunkPosition << 44 >> 44);
this.chunkZ = (int) (chunkPosition << 22 >> 42); this.chunkZ = (int) (chunkPosition << 22 >> 42);
this.ignoreOldLight = in.readBoolean();
this.entries = new BlockChangeEntry[helper.readVarInt(in)]; this.entries = new BlockChangeEntry[helper.readVarInt(in)];
for (int index = 0; index < this.entries.length; index++) { for (int index = 0; index < this.entries.length; index++) {
long blockData = helper.readVarLong(in); long blockData = helper.readVarLong(in);
@ -58,7 +55,6 @@ public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket {
chunkPosition |= (this.chunkX & 0x3FFFFFL) << 42; chunkPosition |= (this.chunkX & 0x3FFFFFL) << 42;
chunkPosition |= (this.chunkZ & 0x3FFFFFL) << 20; chunkPosition |= (this.chunkZ & 0x3FFFFFL) << 20;
out.writeLong(chunkPosition | (this.chunkY & 0xFFFFFL)); out.writeLong(chunkPosition | (this.chunkY & 0xFFFFFL));
out.writeBoolean(this.ignoreOldLight);
helper.writeVarInt(out, this.entries.length); helper.writeVarInt(out, this.entries.length);
for (BlockChangeEntry entry : this.entries) { for (BlockChangeEntry entry : this.entries) {
short position = (short) ((entry.getPosition().getX() - (this.chunkX << 4)) << 8 | (entry.getPosition().getZ() - (this.chunkZ << 4)) << 4 | (entry.getPosition().getY() - (this.chunkY << 4))); short position = (short) ((entry.getPosition().getX() - (this.chunkX << 4)) << 8 | (entry.getPosition().getZ() - (this.chunkZ << 4)) << 4 | (entry.getPosition().getY() - (this.chunkY << 4)));

View file

@ -16,18 +16,21 @@ import java.util.Arrays;
public class ServerboundSignUpdatePacket implements MinecraftPacket { public class ServerboundSignUpdatePacket implements MinecraftPacket {
private final @NonNull Vector3i position; private final @NonNull Vector3i position;
private final @NonNull String[] lines; private final @NonNull String[] lines;
private final boolean isFrontText;
public ServerboundSignUpdatePacket(@NonNull Vector3i position, @NonNull String[] lines) { public ServerboundSignUpdatePacket(@NonNull Vector3i position, @NonNull String[] lines, boolean isFrontText) {
if (lines.length != 4) { if (lines.length != 4) {
throw new IllegalArgumentException("Lines must contain exactly 4 strings."); throw new IllegalArgumentException("Lines must contain exactly 4 strings.");
} }
this.position = position; this.position = position;
this.lines = Arrays.copyOf(lines, lines.length); this.lines = Arrays.copyOf(lines, lines.length);
this.isFrontText = isFrontText;
} }
public ServerboundSignUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { public ServerboundSignUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) {
this.position = helper.readPosition(in); this.position = helper.readPosition(in);
this.isFrontText = in.readBoolean();
this.lines = new String[4]; this.lines = new String[4];
for (int count = 0; count < this.lines.length; count++) { for (int count = 0; count < this.lines.length; count++) {
this.lines[count] = helper.readString(in); this.lines[count] = helper.readString(in);
@ -35,8 +38,9 @@ public class ServerboundSignUpdatePacket implements MinecraftPacket {
} }
@Override @Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writePosition(out, this.position); helper.writePosition(out, this.position);
out.writeBoolean(this.isFrontText);
for (String line : this.lines) { for (String line : this.lines) {
helper.writeString(out, line); helper.writeString(out, line);
} }

View file

@ -51,7 +51,7 @@ public class MinecraftProtocolTest {
null, null,
false false
); );
private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, new String[]{"minecraft:world"}, loadLoginRegistry(), "overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false, null); private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, new String[]{"minecraft:world"}, loadLoginRegistry(), "overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false, null, 100);
private static Server server; private static Server server;

View file

@ -8,7 +8,6 @@ import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
import com.github.steveice10.mc.protocol.data.game.recipe.data.CookedRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.CookedRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.LegacyUpgradeRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.SmithingTransformRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.SmithingTransformRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData;
import com.github.steveice10.mc.protocol.packet.PacketTest; import com.github.steveice10.mc.protocol.packet.PacketTest;
@ -93,16 +92,19 @@ public class ServerDeclareRecipesTest extends PacketTest {
) )
), ),
new Recipe( new Recipe(
RecipeType.SMITHING, RecipeType.SMITHING_TRANSFORM,
"minecraft:Recipe5", "minecraft:Recipe5",
new LegacyUpgradeRecipeData( new SmithingTransformRecipeData(
new Ingredient(new ItemStack[]{ new Ingredient(new ItemStack[]{
new ItemStack(10) new ItemStack(10)
}), }),
new Ingredient(new ItemStack[]{ new Ingredient(new ItemStack[]{
new ItemStack(11) new ItemStack(11)
}), }),
new ItemStack(12) new Ingredient(new ItemStack[]{
new ItemStack(12)
}),
new ItemStack(13)
) )
) )
} }

View file

@ -17,12 +17,12 @@ public class ClientboundLevelChunkWithLightPacketTest extends PacketTest {
this.setPackets( this.setPackets(
new ClientboundLevelChunkWithLightPacket(0, 0, new ClientboundLevelChunkWithLightPacket(0, 0,
new byte[0], new CompoundTag("HeightMaps"), new BlockEntityInfo[0], new byte[0], new CompoundTag("HeightMaps"), new BlockEntityInfo[0],
new LightUpdateData(new BitSet(), new BitSet(), new BitSet(), new BitSet(), Collections.emptyList(), Collections.emptyList(), false) new LightUpdateData(new BitSet(), new BitSet(), new BitSet(), new BitSet(), Collections.emptyList(), Collections.emptyList())
), ),
new ClientboundLevelChunkWithLightPacket(1, 1, new ClientboundLevelChunkWithLightPacket(1, 1,
new byte[256], new CompoundTag("HeightMaps"), new BlockEntityInfo[] { new byte[256], new CompoundTag("HeightMaps"), new BlockEntityInfo[] {
new BlockEntityInfo(1, 0, 1, BlockEntityType.CHEST, null) new BlockEntityInfo(1, 0, 1, BlockEntityType.CHEST, null)
}, new LightUpdateData(new BitSet(), new BitSet(), new BitSet(), new BitSet(), Collections.emptyList(), Collections.emptyList(), true) }, new LightUpdateData(new BitSet(), new BitSet(), new BitSet(), new BitSet(), Collections.emptyList(), Collections.emptyList())
) )
); );
} }

View file

@ -10,7 +10,7 @@ public class ClientboundSectionBlocksUpdatePacketTest extends PacketTest {
@Before @Before
public void setup() { public void setup() {
this.setPackets( this.setPackets(
new ClientboundSectionBlocksUpdatePacket(3, 4, 12, false, new BlockChangeEntry(Vector3i.from(50, 65, 200), 3)) new ClientboundSectionBlocksUpdatePacket(3, 4, 12, new BlockChangeEntry(Vector3i.from(50, 65, 200), 3))
); );
} }

Binary file not shown.