mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2025-06-28 20:50:22 -04:00
Remove IOExceptions from packet handling (#783)
This commit is contained in:
parent
4f2e7a5b55
commit
f2bc83c2c2
86 changed files with 187 additions and 280 deletions
buildSrc
gradle
protocol/src
main/java/org/geysermc/mcprotocollib
network
protocol
CheckedBiConsumer.javaCheckedFunction.javaMinecraftProtocol.java
codec
data/game
packet
common/clientbound
configuration/clientbound
ingame
clientbound
ClientboundBossEventPacket.javaClientboundCommandSuggestionsPacket.javaClientboundDisguisedChatPacket.javaClientboundPlayerChatPacket.javaClientboundPlayerInfoUpdatePacket.javaClientboundServerDataPacket.javaClientboundSystemChatPacket.javaClientboundTabListPacket.javaClientboundUpdateAdvancementsPacket.javaClientboundUpdateRecipesPacket.java
entity
ClientboundSetEntityDataPacket.javaClientboundSetEquipmentPacket.javaClientboundUpdateMobEffectPacket.java
player
inventory
ClientboundContainerSetContentPacket.javaClientboundContainerSetSlotPacket.javaClientboundMerchantOffersPacket.javaClientboundOpenScreenPacket.java
level
ClientboundBlockEntityDataPacket.javaClientboundExplodePacket.javaClientboundLevelChunkWithLightPacket.javaClientboundLevelParticlesPacket.javaClientboundMapItemDataPacket.javaClientboundTagQueryPacket.java
scoreboard
title
serverbound
login/clientbound
test/java/org/geysermc/mcprotocollib/protocol
MinecraftProtocolTest.java
data
packet
PacketTest.java
handshake/serverbound
ingame/clientbound
login
clientbound
ClientboundCustomQueryPacketTest.javaClientboundGameProfilePacketTest.javaClientboundHelloPacketTest.javaClientboundLoginCompressionPacketTest.javaClientboundLoginDisconnectPacketTest.java
serverbound
status
|
@ -7,6 +7,9 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// this is OK as long as the same version catalog is used in the main build and build-logic
|
||||||
|
// see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||||
|
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
implementation(libs.indra.common)
|
implementation(libs.indra.common)
|
||||||
implementation(libs.indra.git)
|
implementation(libs.indra.git)
|
||||||
implementation(libs.lombok)
|
implementation(libs.lombok)
|
||||||
|
|
6
buildSrc/src/main/kotlin/LibsAccessor.kt
Normal file
6
buildSrc/src/main/kotlin/LibsAccessor.kt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import org.gradle.accessors.dm.LibrariesForLibs
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
|
||||||
|
val Project.libs: LibrariesForLibs
|
||||||
|
get() = rootProject.extensions.getByType()
|
|
@ -19,14 +19,7 @@ indra {
|
||||||
}
|
}
|
||||||
|
|
||||||
lombok {
|
lombok {
|
||||||
// ugh https://discuss.gradle.org/t/precompiled-script-plugin-accessing-another-precompiled-script-plugin-extension/46177/4
|
version = libs.versions.lombok.version.get()
|
||||||
version = project.rootProject
|
|
||||||
.extensions
|
|
||||||
.getByType(VersionCatalogsExtension::class.java)
|
|
||||||
.named("libs")
|
|
||||||
.findVersion("lombok")
|
|
||||||
.get()
|
|
||||||
.displayName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<JavaCompile> {
|
tasks.withType<JavaCompile> {
|
||||||
|
@ -38,4 +31,4 @@ tasks.withType<Javadoc> {
|
||||||
val options = options as StandardJavadocDocletOptions
|
val options = options as StandardJavadocDocletOptions
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.addStringOption("Xdoclint:all,-missing", "-quiet")
|
options.addStringOption("Xdoclint:all,-missing", "-quiet")
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ junit = "5.8.2"
|
||||||
|
|
||||||
# buildSrc
|
# buildSrc
|
||||||
indra = "3.1.3"
|
indra = "3.1.3"
|
||||||
lombok = "1.18.30"
|
lombok-version = "1.18.30"
|
||||||
lombok-plugin = "8.4"
|
lombok-plugin = "8.4"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
|
@ -3,8 +3,6 @@ package org.geysermc.mcprotocollib.network.codec;
|
||||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a definition of a packet with various
|
* Represents a definition of a packet with various
|
||||||
* information about it, such as it's id, class and
|
* information about it, such as it's id, class and
|
||||||
|
@ -50,7 +48,7 @@ public class PacketDefinition<T extends Packet, H extends PacketCodecHelper> {
|
||||||
return this.serializer;
|
return this.serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T newInstance(ByteBuf buf, H helper) throws IOException {
|
public T newInstance(ByteBuf buf, H helper) {
|
||||||
return this.serializer.deserialize(buf, helper, this);
|
return this.serializer.deserialize(buf, helper, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,9 @@ package org.geysermc.mcprotocollib.network.codec;
|
||||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public interface PacketSerializer<T extends Packet, H extends PacketCodecHelper> {
|
public interface PacketSerializer<T extends Packet, H extends PacketCodecHelper> {
|
||||||
|
|
||||||
void serialize(ByteBuf buf, H helper, T packet) throws IOException;
|
void serialize(ByteBuf buf, H helper, T packet);
|
||||||
|
|
||||||
T deserialize(ByteBuf buf, H helper, PacketDefinition<T, H> definition) throws IOException;
|
T deserialize(ByteBuf buf, H helper, PacketDefinition<T, H> definition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import io.netty.buffer.ByteBuf;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -145,11 +144,10 @@ public abstract class PacketProtocol {
|
||||||
* @param buf The buffer to read the packet from.
|
* @param buf The buffer to read the packet from.
|
||||||
* @param codecHelper The codec helper.
|
* @param codecHelper The codec helper.
|
||||||
* @return The created packet.
|
* @return The created packet.
|
||||||
* @throws IOException if there was an IO error whilst reading the packet.
|
|
||||||
* @throws IllegalArgumentException If the packet ID is not registered.
|
* @throws IllegalArgumentException If the packet ID is not registered.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <H extends PacketCodecHelper> Packet createClientboundPacket(int id, ByteBuf buf, H codecHelper) throws IOException {
|
public <H extends PacketCodecHelper> Packet createClientboundPacket(int id, ByteBuf buf, H codecHelper) {
|
||||||
PacketDefinition<?, H> definition = (PacketDefinition<?, H>) this.clientbound.get(id);
|
PacketDefinition<?, H> definition = (PacketDefinition<?, H>) this.clientbound.get(id);
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
throw new IllegalArgumentException("Invalid packet id: " + id);
|
throw new IllegalArgumentException("Invalid packet id: " + id);
|
||||||
|
@ -211,11 +209,10 @@ public abstract class PacketProtocol {
|
||||||
* @param buf The buffer to read the packet from.
|
* @param buf The buffer to read the packet from.
|
||||||
* @param codecHelper The codec helper.
|
* @param codecHelper The codec helper.
|
||||||
* @return The created packet.
|
* @return The created packet.
|
||||||
* @throws IOException if there was an IO error whilst reading the packet.
|
|
||||||
* @throws IllegalArgumentException If the packet ID is not registered.
|
* @throws IllegalArgumentException If the packet ID is not registered.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <H extends PacketCodecHelper> Packet createServerboundPacket(int id, ByteBuf buf, H codecHelper) throws IOException {
|
public <H extends PacketCodecHelper> Packet createServerboundPacket(int id, ByteBuf buf, H codecHelper) {
|
||||||
PacketDefinition<?, H> definition = (PacketDefinition<?, H>) this.serverbound.get(id);
|
PacketDefinition<?, H> definition = (PacketDefinition<?, H>) this.serverbound.get(id);
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
throw new IllegalArgumentException("Invalid packet id: " + id);
|
throw new IllegalArgumentException("Invalid packet id: " + id);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class TcpPacketCodec extends ByteToMessageCodec<Packet> {
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf buf) throws Exception {
|
public void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf buf) {
|
||||||
int initial = buf.writerIndex();
|
int initial = buf.writerIndex();
|
||||||
|
|
||||||
PacketProtocol packetProtocol = this.session.getPacketProtocol();
|
PacketProtocol packetProtocol = this.session.getPacketProtocol();
|
||||||
|
@ -47,7 +47,7 @@ public class TcpPacketCodec extends ByteToMessageCodec<Packet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) {
|
||||||
int initial = buf.readerIndex();
|
int initial = buf.readerIndex();
|
||||||
|
|
||||||
PacketProtocol packetProtocol = this.session.getPacketProtocol();
|
PacketProtocol packetProtocol = this.session.getPacketProtocol();
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package org.geysermc.mcprotocollib.protocol;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface CheckedBiConsumer<T, U, E extends Throwable> {
|
|
||||||
void accept(T t, U u) throws E;
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package org.geysermc.mcprotocollib.protocol;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface CheckedFunction<T, R, E extends Throwable> {
|
|
||||||
R apply(T t) throws E;
|
|
||||||
}
|
|
|
@ -25,7 +25,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
|
@ -203,7 +202,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet createClientboundPacket(int id, ByteBuf buf, PacketCodecHelper codecHelper) throws IOException {
|
public Packet createClientboundPacket(int id, ByteBuf buf, PacketCodecHelper codecHelper) {
|
||||||
return this.stateCodec.createClientboundPacket(id, buf, codecHelper);
|
return this.stateCodec.createClientboundPacket(id, buf, codecHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +222,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet createServerboundPacket(int id, ByteBuf buf, PacketCodecHelper codecHelper) throws IOException {
|
public Packet createServerboundPacket(int id, ByteBuf buf, PacketCodecHelper codecHelper) {
|
||||||
return this.stateCodec.createServerboundPacket(id, buf, codecHelper);
|
return this.stateCodec.createServerboundPacket(id, buf, codecHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package org.geysermc.mcprotocollib.protocol.codec;
|
package org.geysermc.mcprotocollib.protocol.codec;
|
||||||
|
|
||||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||||
import org.geysermc.mcprotocollib.protocol.CheckedBiConsumer;
|
|
||||||
import org.geysermc.mcprotocollib.protocol.CheckedFunction;
|
|
||||||
import org.geysermc.mcprotocollib.protocol.data.DefaultComponentSerializer;
|
import org.geysermc.mcprotocollib.protocol.data.DefaultComponentSerializer;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
|
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.chat.numbers.BlankFormat;
|
import org.geysermc.mcprotocollib.protocol.data.game.chat.numbers.BlankFormat;
|
||||||
|
@ -86,6 +84,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
import java.util.function.ObjIntConsumer;
|
import java.util.function.ObjIntConsumer;
|
||||||
|
@ -105,7 +104,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
protected CompoundTag registry;
|
protected CompoundTag registry;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T, E extends Throwable> T readNullable(ByteBuf buf, CheckedFunction<ByteBuf, T, E> ifPresent) throws E {
|
public <T> T readNullable(ByteBuf buf, Function<ByteBuf, T> ifPresent) {
|
||||||
if (buf.readBoolean()) {
|
if (buf.readBoolean()) {
|
||||||
return ifPresent.apply(buf);
|
return ifPresent.apply(buf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,7 +112,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T, E extends Throwable> void writeNullable(ByteBuf buf, @Nullable T value, CheckedBiConsumer<ByteBuf, T, E> ifPresent) throws E {
|
public <T> void writeNullable(ByteBuf buf, @Nullable T value, BiConsumer<ByteBuf, T> ifPresent) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
buf.writeBoolean(true);
|
buf.writeBoolean(true);
|
||||||
ifPresent.accept(buf, value);
|
ifPresent.accept(buf, value);
|
||||||
|
@ -189,12 +188,12 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CompoundTag readAnyTag(ByteBuf buf) throws IOException {
|
public CompoundTag readAnyTag(ByteBuf buf) {
|
||||||
return readAnyTag(buf, CompoundTag.class);
|
return readAnyTag(buf, CompoundTag.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public CompoundTag readAnyTagOrThrow(ByteBuf buf) throws IOException {
|
public CompoundTag readAnyTagOrThrow(ByteBuf buf) {
|
||||||
CompoundTag tag = readAnyTag(buf);
|
CompoundTag tag = readAnyTag(buf);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
throw new IllegalArgumentException("Got end-tag when trying to read CompoundTag");
|
throw new IllegalArgumentException("Got end-tag when trying to read CompoundTag");
|
||||||
|
@ -203,13 +202,18 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends Tag> T readAnyTag(ByteBuf buf, Class<T> expected) throws IOException {
|
public <T extends Tag> T readAnyTag(ByteBuf buf, Class<T> expected) {
|
||||||
Tag tag = NBTIO.readAnyTag(new InputStream() {
|
Tag tag;
|
||||||
@Override
|
try {
|
||||||
public int read() {
|
tag = NBTIO.readAnyTag(new InputStream() {
|
||||||
return buf.readUnsignedByte();
|
@Override
|
||||||
}
|
public int read() {
|
||||||
});
|
return buf.readUnsignedByte();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalArgumentException(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -222,17 +226,21 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
return expected.cast(tag);
|
return expected.cast(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Tag> void writeAnyTag(ByteBuf buf, @Nullable T tag) throws IOException {
|
public <T extends Tag> void writeAnyTag(ByteBuf buf, @Nullable T tag) {
|
||||||
NBTIO.writeAnyTag(new OutputStream() {
|
try {
|
||||||
@Override
|
NBTIO.writeAnyTag(new OutputStream() {
|
||||||
public void write(int b) {
|
@Override
|
||||||
buf.writeByte(b);
|
public void write(int b) {
|
||||||
}
|
buf.writeByte(b);
|
||||||
}, tag);
|
}
|
||||||
|
}, tag);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalArgumentException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack readItemStack(ByteBuf buf) throws IOException {
|
public ItemStack readItemStack(ByteBuf buf) {
|
||||||
boolean present = buf.readBoolean();
|
boolean present = buf.readBoolean();
|
||||||
if (!present) {
|
if (!present) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -242,7 +250,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
return new ItemStack(item, buf.readByte(), this.readAnyTag(buf));
|
return new ItemStack(item, buf.readByte(), this.readAnyTag(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeItemStack(ByteBuf buf, @Nullable ItemStack item) throws IOException {
|
public void writeItemStack(ByteBuf buf, @Nullable ItemStack item) {
|
||||||
buf.writeBoolean(item != null);
|
buf.writeBoolean(item != null);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
this.writeVarInt(buf, item.getId());
|
this.writeVarInt(buf, item.getId());
|
||||||
|
@ -335,7 +343,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
this.writeVarInt(buf, e.ordinal());
|
this.writeVarInt(buf, e.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component readComponent(ByteBuf buf) throws IOException {
|
public Component readComponent(ByteBuf buf) {
|
||||||
// do not use CompoundTag, as mojang serializes a plaintext component as just a single StringTag
|
// do not use CompoundTag, as mojang serializes a plaintext component as just a single StringTag
|
||||||
Tag tag = readAnyTag(buf, Tag.class);
|
Tag tag = readAnyTag(buf, Tag.class);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
|
@ -345,13 +353,13 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
return DefaultComponentSerializer.get().deserializeFromTree(json);
|
return DefaultComponentSerializer.get().deserializeFromTree(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeComponent(ByteBuf buf, Component component) throws IOException {
|
public void writeComponent(ByteBuf buf, Component component) {
|
||||||
JsonElement json = DefaultComponentSerializer.get().serializeToTree(component);
|
JsonElement json = DefaultComponentSerializer.get().serializeToTree(component);
|
||||||
Tag tag = NbtComponentSerializer.jsonComponentToTag(json);
|
Tag tag = NbtComponentSerializer.jsonComponentToTag(json);
|
||||||
writeAnyTag(buf, tag);
|
writeAnyTag(buf, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityMetadata<?, ?>[] readEntityMetadata(ByteBuf buf) throws IOException {
|
public EntityMetadata<?, ?>[] readEntityMetadata(ByteBuf buf) {
|
||||||
List<EntityMetadata<?, ?>> ret = new ArrayList<>();
|
List<EntityMetadata<?, ?>> ret = new ArrayList<>();
|
||||||
int id;
|
int id;
|
||||||
while ((id = buf.readUnsignedByte()) != 255) {
|
while ((id = buf.readUnsignedByte()) != 255) {
|
||||||
|
@ -361,7 +369,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
return ret.toArray(new EntityMetadata<?, ?>[0]);
|
return ret.toArray(new EntityMetadata<?, ?>[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeEntityMetadata(ByteBuf buf, EntityMetadata<?, ?>[] metadata) throws IOException {
|
public void writeEntityMetadata(ByteBuf buf, EntityMetadata<?, ?>[] metadata) {
|
||||||
for (EntityMetadata<?, ?> meta : metadata) {
|
for (EntityMetadata<?, ?> meta : metadata) {
|
||||||
this.writeMetadata(buf, meta);
|
this.writeMetadata(buf, meta);
|
||||||
}
|
}
|
||||||
|
@ -369,12 +377,12 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
buf.writeByte(255);
|
buf.writeByte(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityMetadata<?, ?> readMetadata(ByteBuf buf, int id) throws IOException {
|
public EntityMetadata<?, ?> readMetadata(ByteBuf buf, int id) {
|
||||||
MetadataType<?> type = this.readMetadataType(buf);
|
MetadataType<?> type = this.readMetadataType(buf);
|
||||||
return type.readMetadata(this, buf, id);
|
return type.readMetadata(this, buf, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeMetadata(ByteBuf buf, EntityMetadata<?, ?> metadata) throws IOException {
|
public void writeMetadata(ByteBuf buf, EntityMetadata<?, ?> metadata) {
|
||||||
buf.writeByte(metadata.getId());
|
buf.writeByte(metadata.getId());
|
||||||
this.writeMetadataType(buf, metadata.getType());
|
this.writeMetadataType(buf, metadata.getType());
|
||||||
metadata.write(this, buf);
|
metadata.write(this, buf);
|
||||||
|
@ -437,19 +445,22 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
this.writeEnum(buf, type);
|
this.writeEnum(buf, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Particle readParticle(ByteBuf buf) throws IOException {
|
public Particle readParticle(ByteBuf buf) {
|
||||||
ParticleType particleType = this.readParticleType(buf);
|
ParticleType particleType = this.readParticleType(buf);
|
||||||
return new Particle(particleType, this.readParticleData(buf, particleType));
|
return new Particle(particleType, this.readParticleData(buf, particleType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeParticle(ByteBuf buf, Particle particle) throws IOException {
|
public void writeParticle(ByteBuf buf, Particle particle) {
|
||||||
this.writeEnum(buf, particle.getType());
|
this.writeEnum(buf, particle.getType());
|
||||||
this.writeParticleData(buf, particle.getType(), particle.getData());
|
this.writeParticleData(buf, particle.getType(), particle.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleData readParticleData(ByteBuf buf, ParticleType type) throws IOException {
|
public ParticleData readParticleData(ByteBuf buf, ParticleType type) {
|
||||||
return switch (type) {
|
return switch (type) {
|
||||||
case BLOCK, BLOCK_MARKER -> new BlockParticleData(this.readVarInt(buf));
|
case BLOCK, BLOCK_MARKER -> {
|
||||||
|
int blockState = this.readVarInt(buf);
|
||||||
|
yield new BlockParticleData(blockState);
|
||||||
|
}
|
||||||
case DUST -> {
|
case DUST -> {
|
||||||
float red = buf.readFloat();
|
float red = buf.readFloat();
|
||||||
float green = buf.readFloat();
|
float green = buf.readFloat();
|
||||||
|
@ -476,9 +487,12 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeParticleData(ByteBuf buf, ParticleType type, ParticleData data) throws IOException {
|
public void writeParticleData(ByteBuf buf, ParticleType type, ParticleData data) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BLOCK, BLOCK_MARKER -> this.writeVarInt(buf, ((BlockParticleData) data).getBlockState());
|
case BLOCK, BLOCK_MARKER -> {
|
||||||
|
BlockParticleData block = (BlockParticleData) data;
|
||||||
|
this.writeVarInt(buf, block.getBlockState());
|
||||||
|
}
|
||||||
case DUST -> {
|
case DUST -> {
|
||||||
DustParticleData dust = (DustParticleData) data;
|
DustParticleData dust = (DustParticleData) data;
|
||||||
buf.writeFloat(dust.getRed());
|
buf.writeFloat(dust.getRed());
|
||||||
|
@ -521,7 +535,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NumberFormat readNumberFormat(ByteBuf buf) throws IOException {
|
public NumberFormat readNumberFormat(ByteBuf buf) {
|
||||||
int id = this.readVarInt(buf);
|
int id = this.readVarInt(buf);
|
||||||
return switch (id) {
|
return switch (id) {
|
||||||
case 0 -> BlankFormat.INSTANCE;
|
case 0 -> BlankFormat.INSTANCE;
|
||||||
|
@ -531,7 +545,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNumberFormat(ByteBuf buf, NumberFormat numberFormat) throws IOException {
|
public void writeNumberFormat(ByteBuf buf, NumberFormat numberFormat) {
|
||||||
if (numberFormat instanceof BlankFormat) {
|
if (numberFormat instanceof BlankFormat) {
|
||||||
this.writeVarInt(buf, 0);
|
this.writeVarInt(buf, 0);
|
||||||
} else if (numberFormat instanceof StyledFormat styledFormat) {
|
} else if (numberFormat instanceof StyledFormat styledFormat) {
|
||||||
|
@ -708,7 +722,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
buf.writeByte(event.ordinal());
|
buf.writeByte(event.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ingredient readRecipeIngredient(ByteBuf buf) throws IOException {
|
public Ingredient readRecipeIngredient(ByteBuf buf) {
|
||||||
ItemStack[] options = new ItemStack[this.readVarInt(buf)];
|
ItemStack[] options = new ItemStack[this.readVarInt(buf)];
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
options[i] = this.readItemStack(buf);
|
options[i] = this.readItemStack(buf);
|
||||||
|
@ -717,14 +731,14 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
return new Ingredient(options);
|
return new Ingredient(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRecipeIngredient(ByteBuf buf, Ingredient ingredient) throws IOException {
|
public void writeRecipeIngredient(ByteBuf buf, Ingredient ingredient) {
|
||||||
this.writeVarInt(buf, ingredient.getOptions().length);
|
this.writeVarInt(buf, ingredient.getOptions().length);
|
||||||
for (ItemStack option : ingredient.getOptions()) {
|
for (ItemStack option : ingredient.getOptions()) {
|
||||||
this.writeItemStack(buf, option);
|
this.writeItemStack(buf, option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataPalette readDataPalette(ByteBuf buf, PaletteType paletteType) throws IOException {
|
public DataPalette readDataPalette(ByteBuf buf, PaletteType paletteType) {
|
||||||
int bitsPerEntry = buf.readByte() & 0xFF;
|
int bitsPerEntry = buf.readByte() & 0xFF;
|
||||||
Palette palette = this.readPalette(buf, paletteType, bitsPerEntry);
|
Palette palette = this.readPalette(buf, paletteType, bitsPerEntry);
|
||||||
BitStorage storage;
|
BitStorage storage;
|
||||||
|
@ -746,7 +760,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
* @deprecated globalPaletteBits is no longer in use, use {@link #readDataPalette(ByteBuf, PaletteType)} instead.
|
* @deprecated globalPaletteBits is no longer in use, use {@link #readDataPalette(ByteBuf, PaletteType)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public DataPalette readDataPalette(ByteBuf buf, PaletteType paletteType, int globalPaletteBits) throws IOException {
|
public DataPalette readDataPalette(ByteBuf buf, PaletteType paletteType, int globalPaletteBits) {
|
||||||
return this.readDataPalette(buf, paletteType);
|
return this.readDataPalette(buf, paletteType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +799,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkSection readChunkSection(ByteBuf buf) throws IOException {
|
public ChunkSection readChunkSection(ByteBuf buf) {
|
||||||
int blockCount = buf.readShort();
|
int blockCount = buf.readShort();
|
||||||
|
|
||||||
DataPalette chunkPalette = this.readDataPalette(buf, PaletteType.CHUNK);
|
DataPalette chunkPalette = this.readDataPalette(buf, PaletteType.CHUNK);
|
||||||
|
@ -797,7 +811,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
||||||
* @deprecated globalBiomePaletteBits is no longer in use, use {@link #readChunkSection(ByteBuf)} instead.
|
* @deprecated globalBiomePaletteBits is no longer in use, use {@link #readChunkSection(ByteBuf)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public ChunkSection readChunkSection(ByteBuf buf, int globalBiomePaletteBits) throws IOException {
|
public ChunkSection readChunkSection(ByteBuf buf, int globalBiomePaletteBits) {
|
||||||
return this.readChunkSection(buf);
|
return this.readChunkSection(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,7 @@ package org.geysermc.mcprotocollib.protocol.codec;
|
||||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public interface MinecraftPacket extends Packet {
|
public interface MinecraftPacket extends Packet {
|
||||||
|
|
||||||
void serialize(ByteBuf buf, MinecraftCodecHelper helper) throws IOException;
|
void serialize(ByteBuf buf, MinecraftCodecHelper helper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,19 +5,17 @@ import org.geysermc.mcprotocollib.network.codec.PacketSerializer;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MinecraftPacketSerializer<T extends MinecraftPacket> implements PacketSerializer<T, MinecraftCodecHelper> {
|
public class MinecraftPacketSerializer<T extends MinecraftPacket> implements PacketSerializer<T, MinecraftCodecHelper> {
|
||||||
private final PacketFactory<T, MinecraftCodecHelper> factory;
|
private final PacketFactory<T, MinecraftCodecHelper> factory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf buf, MinecraftCodecHelper helper, T packet) throws IOException {
|
public void serialize(ByteBuf buf, MinecraftCodecHelper helper, T packet) {
|
||||||
packet.serialize(buf, helper);
|
packet.serialize(buf, helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T deserialize(ByteBuf buf, MinecraftCodecHelper helper, PacketDefinition<T, MinecraftCodecHelper> definition) throws IOException {
|
public T deserialize(ByteBuf buf, MinecraftCodecHelper helper, PacketDefinition<T, MinecraftCodecHelper> definition) {
|
||||||
return this.factory.construct(buf, helper);
|
return this.factory.construct(buf, helper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@ import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
|
||||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory for constructing {@link Packet}s.
|
* Factory for constructing {@link Packet}s.
|
||||||
*
|
*
|
||||||
|
@ -21,5 +19,5 @@ public interface PacketFactory<T extends Packet, H extends PacketCodecHelper> {
|
||||||
* @param codecHelper the codec helper
|
* @param codecHelper the codec helper
|
||||||
* @return a new packet from the input
|
* @return a new packet from the input
|
||||||
*/
|
*/
|
||||||
T construct(ByteBuf buf, H codecHelper) throws IOException;
|
T construct(ByteBuf buf, H codecHelper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -25,7 +24,7 @@ public abstract class EntityMetadata<V, T extends MetadataType<V>> {
|
||||||
* Overridden for primitive classes. This write method still checks for these primitives in the event
|
* Overridden for primitive classes. This write method still checks for these primitives in the event
|
||||||
* they are manually created using {@link ObjectEntityMetadata}.
|
* they are manually created using {@link ObjectEntityMetadata}.
|
||||||
*/
|
*/
|
||||||
public void write(MinecraftCodecHelper helper, ByteBuf out) throws IOException {
|
public void write(MinecraftCodecHelper helper, ByteBuf out) {
|
||||||
this.type.writeMetadata(helper, out, this.getValue());
|
this.type.writeMetadata(helper, out, this.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import org.cloudburstmc.math.vector.Vector4f;
|
import org.cloudburstmc.math.vector.Vector4f;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -71,38 +70,38 @@ public class MetadataType<T> {
|
||||||
VALUES.add(this);
|
VALUES.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityMetadata<T, ? extends MetadataType<T>> readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) throws IOException {
|
public EntityMetadata<T, ? extends MetadataType<T>> readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) {
|
||||||
return this.metadataFactory.create(id, this, this.reader.read(helper, input));
|
return this.metadataFactory.create(id, this, this.reader.read(helper, input));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeMetadata(MinecraftCodecHelper helper, ByteBuf output, T value) throws IOException {
|
public void writeMetadata(MinecraftCodecHelper helper, ByteBuf output, T value) {
|
||||||
this.writer.write(helper, output, value);
|
this.writer.write(helper, output, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Reader<V> {
|
public interface Reader<V> {
|
||||||
V read(MinecraftCodecHelper helper, ByteBuf input) throws IOException;
|
V read(MinecraftCodecHelper helper, ByteBuf input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Writer<V> {
|
public interface Writer<V> {
|
||||||
void write(MinecraftCodecHelper helper, ByteBuf output, V value) throws IOException;
|
void write(MinecraftCodecHelper helper, ByteBuf output, V value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface BasicReader<V> extends Reader<V> {
|
public interface BasicReader<V> extends Reader<V> {
|
||||||
V read(ByteBuf input) throws IOException;
|
V read(ByteBuf input);
|
||||||
|
|
||||||
default V read(MinecraftCodecHelper helper, ByteBuf input) throws IOException {
|
default V read(MinecraftCodecHelper helper, ByteBuf input) {
|
||||||
return this.read(input);
|
return this.read(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface BasicWriter<V> extends Writer<V> {
|
public interface BasicWriter<V> extends Writer<V> {
|
||||||
void write(ByteBuf output, V value) throws IOException;
|
void write(ByteBuf output, V value);
|
||||||
|
|
||||||
default void write(MinecraftCodecHelper helper, ByteBuf output, V value) throws IOException {
|
default void write(MinecraftCodecHelper helper, ByteBuf output, V value) {
|
||||||
this.write(output, value);
|
this.write(output, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,19 +133,15 @@ public class MetadataType<T> {
|
||||||
|
|
||||||
private static <T> BasicWriter<Optional<T>> optionalWriter(BasicWriter<T> writer) {
|
private static <T> BasicWriter<Optional<T>> optionalWriter(BasicWriter<T> writer) {
|
||||||
return (output, value) -> {
|
return (output, value) -> {
|
||||||
output.writeBoolean(value.isPresent());
|
output.writeBoolean(value.isPresent());
|
||||||
if (value.isPresent()) {
|
value.ifPresent(t -> writer.write(output, t));
|
||||||
writer.write(output, value.get());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> Writer<Optional<T>> optionalWriter(Writer<T> writer) {
|
private static <T> Writer<Optional<T>> optionalWriter(Writer<T> writer) {
|
||||||
return (helper, output, value) -> {
|
return (helper, output, value) -> {
|
||||||
output.writeBoolean(value.isPresent());
|
output.writeBoolean(value.isPresent());
|
||||||
if (value.isPresent()) {
|
value.ifPresent(t -> writer.write(helper, output, t));
|
||||||
writer.write(helper, output, value.get());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetad
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class BooleanEntityMetadata extends EntityMetadata<Boolean, BooleanMetadataType> {
|
public class BooleanEntityMetadata extends EntityMetadata<Boolean, BooleanMetadataType> {
|
||||||
private final boolean value;
|
private final boolean value;
|
||||||
|
|
||||||
|
@ -27,7 +25,7 @@ public class BooleanEntityMetadata extends EntityMetadata<Boolean, BooleanMetada
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(MinecraftCodecHelper helper, ByteBuf out) throws IOException {
|
public void write(MinecraftCodecHelper helper, ByteBuf out) {
|
||||||
this.type.writeMetadataPrimitive(out, this.value);
|
this.type.writeMetadataPrimitive(out, this.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetad
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class ByteEntityMetadata extends EntityMetadata<Byte, ByteMetadataType> {
|
public class ByteEntityMetadata extends EntityMetadata<Byte, ByteMetadataType> {
|
||||||
private final byte value;
|
private final byte value;
|
||||||
|
|
||||||
|
@ -27,7 +25,7 @@ public class ByteEntityMetadata extends EntityMetadata<Byte, ByteMetadataType> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(MinecraftCodecHelper helper, ByteBuf out) throws IOException {
|
public void write(MinecraftCodecHelper helper, ByteBuf out) {
|
||||||
this.type.writeMetadataPrimitive(out, this.value);
|
this.type.writeMetadataPrimitive(out, this.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.FloatMetada
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class FloatEntityMetadata extends EntityMetadata<Float, FloatMetadataType> {
|
public class FloatEntityMetadata extends EntityMetadata<Float, FloatMetadataType> {
|
||||||
private final float value;
|
private final float value;
|
||||||
|
|
||||||
|
@ -27,7 +25,7 @@ public class FloatEntityMetadata extends EntityMetadata<Float, FloatMetadataType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(MinecraftCodecHelper helper, ByteBuf out) throws IOException {
|
public void write(MinecraftCodecHelper helper, ByteBuf out) {
|
||||||
this.type.writeMetadataPrimitive(out, this.value);
|
this.type.writeMetadataPrimitive(out, this.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.IntMetadata
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class IntEntityMetadata extends EntityMetadata<Integer, IntMetadataType> {
|
public class IntEntityMetadata extends EntityMetadata<Integer, IntMetadataType> {
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
|
@ -27,7 +25,7 @@ public class IntEntityMetadata extends EntityMetadata<Integer, IntMetadataType>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(MinecraftCodecHelper helper, ByteBuf out) throws IOException {
|
public void write(MinecraftCodecHelper helper, ByteBuf out) {
|
||||||
this.type.writeMetadataPrimitive(helper, out, value);
|
this.type.writeMetadataPrimitive(helper, out, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.LongMetadat
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class LongEntityMetadata extends EntityMetadata<Long, LongMetadataType> {
|
public class LongEntityMetadata extends EntityMetadata<Long, LongMetadataType> {
|
||||||
private final long value;
|
private final long value;
|
||||||
|
|
||||||
|
@ -27,7 +25,7 @@ public class LongEntityMetadata extends EntityMetadata<Long, LongMetadataType> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(MinecraftCodecHelper helper, ByteBuf out) throws IOException {
|
public void write(MinecraftCodecHelper helper, ByteBuf out) {
|
||||||
this.type.writeMetadataPrimitive(helper, out, value);
|
this.type.writeMetadataPrimitive(helper, out, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -44,7 +43,7 @@ public class LightUpdateData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void write(ByteBuf out, MinecraftCodecHelper helper, LightUpdateData data) throws IOException {
|
public static void write(ByteBuf out, MinecraftCodecHelper helper, LightUpdateData data) {
|
||||||
data.write(out, helper);
|
data.write(out, helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -22,12 +20,12 @@ public class ClientboundDisconnectPacket implements MinecraftPacket {
|
||||||
this(DefaultComponentSerializer.get().deserialize(reason));
|
this(DefaultComponentSerializer.get().deserialize(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundDisconnectPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundDisconnectPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.reason = helper.readComponent(in);
|
this.reason = helper.readComponent(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeComponent(out, this.reason);
|
helper.writeComponent(out, this.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -23,7 +22,7 @@ public class ClientboundResourcePackPushPacket implements MinecraftPacket {
|
||||||
private final boolean required;
|
private final boolean required;
|
||||||
private final @Nullable Component prompt;
|
private final @Nullable Component prompt;
|
||||||
|
|
||||||
public ClientboundResourcePackPushPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundResourcePackPushPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.id = helper.readUUID(in);
|
this.id = helper.readUUID(in);
|
||||||
this.url = helper.readString(in);
|
this.url = helper.readString(in);
|
||||||
this.hash = helper.readString(in);
|
this.hash = helper.readString(in);
|
||||||
|
@ -32,7 +31,7 @@ public class ClientboundResourcePackPushPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeUUID(out, this.id);
|
helper.writeUUID(out, this.id);
|
||||||
helper.writeString(out, this.url);
|
helper.writeString(out, this.url);
|
||||||
helper.writeString(out, this.hash);
|
helper.writeString(out, this.hash);
|
||||||
|
|
|
@ -8,20 +8,18 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ClientboundRegistryDataPacket implements MinecraftPacket {
|
public class ClientboundRegistryDataPacket implements MinecraftPacket {
|
||||||
private final CompoundTag registry;
|
private final CompoundTag registry;
|
||||||
|
|
||||||
public ClientboundRegistryDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundRegistryDataPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.registry = helper.readAnyTag(in);
|
this.registry = helper.readAnyTag(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeAnyTag(out, this.registry);
|
helper.writeAnyTag(out, this.registry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import io.netty.buffer.ByteBuf;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -64,7 +63,7 @@ public class ClientboundBossEventPacket implements MinecraftPacket {
|
||||||
this.showFog = showFog;
|
this.showFog = showFog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundBossEventPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundBossEventPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.uuid = helper.readUUID(in);
|
this.uuid = helper.readUUID(in);
|
||||||
this.action = BossBarAction.from(helper.readVarInt(in));
|
this.action = BossBarAction.from(helper.readVarInt(in));
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ public class ClientboundBossEventPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeUUID(out, this.uuid);
|
helper.writeUUID(out, this.uuid);
|
||||||
helper.writeVarInt(out, this.action.ordinal());
|
helper.writeVarInt(out, this.action.ordinal());
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -32,7 +31,7 @@ public class ClientboundCommandSuggestionsPacket implements MinecraftPacket {
|
||||||
this.tooltips = Arrays.copyOf(tooltips, tooltips.length);
|
this.tooltips = Arrays.copyOf(tooltips, tooltips.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundCommandSuggestionsPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundCommandSuggestionsPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.transactionId = helper.readVarInt(in);
|
this.transactionId = helper.readVarInt(in);
|
||||||
this.start = helper.readVarInt(in);
|
this.start = helper.readVarInt(in);
|
||||||
this.length = helper.readVarInt(in);
|
this.length = helper.readVarInt(in);
|
||||||
|
@ -47,7 +46,7 @@ public class ClientboundCommandSuggestionsPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.transactionId);
|
helper.writeVarInt(out, this.transactionId);
|
||||||
helper.writeVarInt(out, this.start);
|
helper.writeVarInt(out, this.start);
|
||||||
helper.writeVarInt(out, this.length);
|
helper.writeVarInt(out, this.length);
|
||||||
|
|
|
@ -10,8 +10,6 @@ import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -25,7 +23,7 @@ public class ClientboundDisguisedChatPacket implements MinecraftPacket {
|
||||||
private final @Nullable Component targetName;
|
private final @Nullable Component targetName;
|
||||||
|
|
||||||
|
|
||||||
public ClientboundDisguisedChatPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundDisguisedChatPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.message = helper.readComponent(in);
|
this.message = helper.readComponent(in);
|
||||||
this.chatType = helper.readVarInt(in);
|
this.chatType = helper.readVarInt(in);
|
||||||
this.name = helper.readComponent(in);
|
this.name = helper.readComponent(in);
|
||||||
|
@ -33,7 +31,7 @@ public class ClientboundDisguisedChatPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeComponent(out, this.message);
|
helper.writeComponent(out, this.message);
|
||||||
helper.writeVarInt(out, this.chatType);
|
helper.writeVarInt(out, this.chatType);
|
||||||
helper.writeComponent(out, this.name);
|
helper.writeComponent(out, this.name);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -37,7 +36,7 @@ public class ClientboundPlayerChatPacket implements MinecraftPacket {
|
||||||
private final Component name;
|
private final Component name;
|
||||||
private final @Nullable Component targetName;
|
private final @Nullable Component targetName;
|
||||||
|
|
||||||
public ClientboundPlayerChatPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundPlayerChatPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.sender = helper.readUUID(in);
|
this.sender = helper.readUUID(in);
|
||||||
this.index = helper.readVarInt(in);
|
this.index = helper.readVarInt(in);
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
|
@ -65,7 +64,7 @@ public class ClientboundPlayerChatPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeUUID(out, this.sender);
|
helper.writeUUID(out, this.sender);
|
||||||
helper.writeVarInt(out, this.index);
|
helper.writeVarInt(out, this.index);
|
||||||
out.writeBoolean(this.messageSignature != null);
|
out.writeBoolean(this.messageSignature != null);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
@ -28,7 +27,7 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket {
|
||||||
private final EnumSet<PlayerListEntryAction> actions;
|
private final EnumSet<PlayerListEntryAction> actions;
|
||||||
private final PlayerListEntry[] entries;
|
private final PlayerListEntry[] entries;
|
||||||
|
|
||||||
public ClientboundPlayerInfoUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundPlayerInfoUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.actions = helper.readEnumSet(in, PlayerListEntryAction.VALUES);
|
this.actions = helper.readEnumSet(in, PlayerListEntryAction.VALUES);
|
||||||
this.entries = new PlayerListEntry[helper.readVarInt(in)];
|
this.entries = new PlayerListEntry[helper.readVarInt(in)];
|
||||||
for (int count = 0; count < this.entries.length; count++) {
|
for (int count = 0; count < this.entries.length; count++) {
|
||||||
|
@ -58,7 +57,7 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket {
|
||||||
try {
|
try {
|
||||||
publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(keyBytes));
|
publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(keyBytes));
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
throw new IOException("Could not decode public key.", e);
|
throw new IllegalStateException("Could not decode public key.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.setPublicKey(publicKey);
|
entry.setPublicKey(publicKey);
|
||||||
|
@ -91,7 +90,7 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeEnumSet(out, this.actions, PlayerListEntryAction.VALUES);
|
helper.writeEnumSet(out, this.actions, PlayerListEntryAction.VALUES);
|
||||||
helper.writeVarInt(out, this.entries.length);
|
helper.writeVarInt(out, this.entries.length);
|
||||||
for (PlayerListEntry entry : this.entries) {
|
for (PlayerListEntry entry : this.entries) {
|
||||||
|
|
|
@ -9,8 +9,6 @@ import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -19,14 +17,14 @@ public class ClientboundServerDataPacket implements MinecraftPacket {
|
||||||
private final byte @Nullable[] iconBytes;
|
private final byte @Nullable[] iconBytes;
|
||||||
private final boolean enforcesSecureChat;
|
private final boolean enforcesSecureChat;
|
||||||
|
|
||||||
public ClientboundServerDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundServerDataPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.motd = helper.readComponent(in);
|
this.motd = helper.readComponent(in);
|
||||||
this.iconBytes = helper.readNullable(in, helper::readByteArray);
|
this.iconBytes = helper.readNullable(in, helper::readByteArray);
|
||||||
this.enforcesSecureChat = in.readBoolean();
|
this.enforcesSecureChat = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeComponent(out, this.motd);
|
helper.writeComponent(out, this.motd);
|
||||||
helper.writeNullable(out, this.iconBytes, helper::writeByteArray);
|
helper.writeNullable(out, this.iconBytes, helper::writeByteArray);
|
||||||
out.writeBoolean(this.enforcesSecureChat);
|
out.writeBoolean(this.enforcesSecureChat);
|
||||||
|
|
|
@ -8,8 +8,6 @@ import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -17,13 +15,13 @@ public class ClientboundSystemChatPacket implements MinecraftPacket {
|
||||||
private final Component content;
|
private final Component content;
|
||||||
private final boolean overlay;
|
private final boolean overlay;
|
||||||
|
|
||||||
public ClientboundSystemChatPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSystemChatPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.content = helper.readComponent(in);
|
this.content = helper.readComponent(in);
|
||||||
this.overlay = in.readBoolean();
|
this.overlay = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeComponent(out, this.content);
|
helper.writeComponent(out, this.content);
|
||||||
out.writeBoolean(this.overlay);
|
out.writeBoolean(this.overlay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -18,13 +16,13 @@ public class ClientboundTabListPacket implements MinecraftPacket {
|
||||||
private final @NonNull Component header;
|
private final @NonNull Component header;
|
||||||
private final @NonNull Component footer;
|
private final @NonNull Component footer;
|
||||||
|
|
||||||
public ClientboundTabListPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundTabListPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.header = helper.readComponent(in);
|
this.header = helper.readComponent(in);
|
||||||
this.footer = helper.readComponent(in);
|
this.footer = helper.readComponent(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeComponent(out, this.header);
|
helper.writeComponent(out, this.header);
|
||||||
helper.writeComponent(out, this.footer);
|
helper.writeComponent(out, this.footer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -45,7 +44,7 @@ public class ClientboundUpdateAdvancementsPacket implements MinecraftPacket {
|
||||||
return progress.get(criterionId);
|
return progress.get(criterionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundUpdateAdvancementsPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundUpdateAdvancementsPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.reset = in.readBoolean();
|
this.reset = in.readBoolean();
|
||||||
|
|
||||||
this.advancements = new Advancement[helper.readVarInt(in)];
|
this.advancements = new Advancement[helper.readVarInt(in)];
|
||||||
|
@ -111,7 +110,7 @@ public class ClientboundUpdateAdvancementsPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
out.writeBoolean(this.reset);
|
out.writeBoolean(this.reset);
|
||||||
|
|
||||||
helper.writeVarInt(out, this.advancements.length);
|
helper.writeVarInt(out, this.advancements.length);
|
||||||
|
|
|
@ -14,15 +14,13 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
private final @NonNull Recipe[] recipes;
|
private final @NonNull Recipe[] recipes;
|
||||||
|
|
||||||
public ClientboundUpdateRecipesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundUpdateRecipesPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.recipes = new Recipe[helper.readVarInt(in)];
|
this.recipes = new Recipe[helper.readVarInt(in)];
|
||||||
for (int i = 0; i < this.recipes.length; i++) {
|
for (int i = 0; i < this.recipes.length; i++) {
|
||||||
RecipeType type = RecipeType.from(helper.readResourceLocation(in));
|
RecipeType type = RecipeType.from(helper.readResourceLocation(in));
|
||||||
|
@ -102,7 +100,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.recipes.length);
|
helper.writeVarInt(out, this.recipes.length);
|
||||||
for (Recipe recipe : this.recipes) {
|
for (Recipe recipe : this.recipes) {
|
||||||
helper.writeResourceLocation(out, recipe.getType().getResourceLocation());
|
helper.writeResourceLocation(out, recipe.getType().getResourceLocation());
|
||||||
|
|
|
@ -9,8 +9,6 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -18,13 +16,13 @@ public class ClientboundSetEntityDataPacket implements MinecraftPacket {
|
||||||
private final int entityId;
|
private final int entityId;
|
||||||
private final @NonNull EntityMetadata<?, ?>[] metadata;
|
private final @NonNull EntityMetadata<?, ?>[] metadata;
|
||||||
|
|
||||||
public ClientboundSetEntityDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetEntityDataPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.entityId = helper.readVarInt(in);
|
this.entityId = helper.readVarInt(in);
|
||||||
this.metadata = helper.readEntityMetadata(in);
|
this.metadata = helper.readEntityMetadata(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.entityId);
|
helper.writeVarInt(out, this.entityId);
|
||||||
helper.writeEntityMetadata(out, this.metadata);
|
helper.writeEntityMetadata(out, this.metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ public class ClientboundSetEquipmentPacket implements MinecraftPacket {
|
||||||
private final int entityId;
|
private final int entityId;
|
||||||
private final @NonNull Equipment[] equipment;
|
private final @NonNull Equipment[] equipment;
|
||||||
|
|
||||||
public ClientboundSetEquipmentPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetEquipmentPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.entityId = helper.readVarInt(in);
|
this.entityId = helper.readVarInt(in);
|
||||||
boolean hasNextEntry = true;
|
boolean hasNextEntry = true;
|
||||||
List<Equipment> list = new ArrayList<>();
|
List<Equipment> list = new ArrayList<>();
|
||||||
|
@ -37,7 +36,7 @@ public class ClientboundSetEquipmentPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.entityId);
|
helper.writeVarInt(out, this.entityId);
|
||||||
for (int i = 0; i < this.equipment.length; i++) {
|
for (int i = 0; i < this.equipment.length; i++) {
|
||||||
int rawSlot = this.equipment[i].getSlot().ordinal();
|
int rawSlot = this.equipment[i].getSlot().ordinal();
|
||||||
|
|
|
@ -11,8 +11,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -30,7 +28,7 @@ public class ClientboundUpdateMobEffectPacket implements MinecraftPacket {
|
||||||
private final boolean showIcon;
|
private final boolean showIcon;
|
||||||
private final @Nullable CompoundTag factorData;
|
private final @Nullable CompoundTag factorData;
|
||||||
|
|
||||||
public ClientboundUpdateMobEffectPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundUpdateMobEffectPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.entityId = helper.readVarInt(in);
|
this.entityId = helper.readVarInt(in);
|
||||||
this.effect = helper.readEffect(in);
|
this.effect = helper.readEffect(in);
|
||||||
this.amplifier = in.readByte();
|
this.amplifier = in.readByte();
|
||||||
|
@ -44,7 +42,7 @@ public class ClientboundUpdateMobEffectPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.entityId);
|
helper.writeVarInt(out, this.entityId);
|
||||||
helper.writeEffect(out, this.effect);
|
helper.writeEffect(out, this.effect);
|
||||||
out.writeByte(this.amplifier);
|
out.writeByte(this.amplifier);
|
||||||
|
|
|
@ -8,8 +8,6 @@ import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -17,13 +15,13 @@ public class ClientboundPlayerCombatKillPacket implements MinecraftPacket {
|
||||||
private final int playerId;
|
private final int playerId;
|
||||||
private final Component message;
|
private final Component message;
|
||||||
|
|
||||||
public ClientboundPlayerCombatKillPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundPlayerCombatKillPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.playerId = helper.readVarInt(in);
|
this.playerId = helper.readVarInt(in);
|
||||||
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) {
|
||||||
helper.writeVarInt(out, this.playerId);
|
helper.writeVarInt(out, this.playerId);
|
||||||
helper.writeComponent(out, this.message);
|
helper.writeComponent(out, this.message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -21,7 +19,7 @@ public class ClientboundContainerSetContentPacket implements MinecraftPacket {
|
||||||
private final @Nullable ItemStack @NonNull [] items;
|
private final @Nullable ItemStack @NonNull [] items;
|
||||||
private final @Nullable ItemStack carriedItem;
|
private final @Nullable ItemStack carriedItem;
|
||||||
|
|
||||||
public ClientboundContainerSetContentPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundContainerSetContentPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.containerId = in.readUnsignedByte();
|
this.containerId = in.readUnsignedByte();
|
||||||
this.stateId = helper.readVarInt(in);
|
this.stateId = helper.readVarInt(in);
|
||||||
this.items = new ItemStack[helper.readVarInt(in)];
|
this.items = new ItemStack[helper.readVarInt(in)];
|
||||||
|
@ -32,7 +30,7 @@ public class ClientboundContainerSetContentPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
out.writeByte(this.containerId);
|
out.writeByte(this.containerId);
|
||||||
helper.writeVarInt(out, this.stateId);
|
helper.writeVarInt(out, this.stateId);
|
||||||
helper.writeVarInt(out, this.items.length);
|
helper.writeVarInt(out, this.items.length);
|
||||||
|
|
|
@ -9,8 +9,6 @@ import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -20,7 +18,7 @@ public class ClientboundContainerSetSlotPacket implements MinecraftPacket {
|
||||||
private final int slot;
|
private final int slot;
|
||||||
private final @Nullable ItemStack item;
|
private final @Nullable ItemStack item;
|
||||||
|
|
||||||
public ClientboundContainerSetSlotPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundContainerSetSlotPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.containerId = in.readUnsignedByte();
|
this.containerId = in.readUnsignedByte();
|
||||||
this.stateId = helper.readVarInt(in);
|
this.stateId = helper.readVarInt(in);
|
||||||
this.slot = in.readShort();
|
this.slot = in.readShort();
|
||||||
|
@ -28,7 +26,7 @@ public class ClientboundContainerSetSlotPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
out.writeByte(this.containerId);
|
out.writeByte(this.containerId);
|
||||||
helper.writeVarInt(out, this.stateId);
|
helper.writeVarInt(out, this.stateId);
|
||||||
out.writeShort(this.slot);
|
out.writeShort(this.slot);
|
||||||
|
|
|
@ -10,8 +10,6 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -23,7 +21,7 @@ public class ClientboundMerchantOffersPacket implements MinecraftPacket {
|
||||||
private final boolean regularVillager;
|
private final boolean regularVillager;
|
||||||
private final boolean canRestock;
|
private final boolean canRestock;
|
||||||
|
|
||||||
public ClientboundMerchantOffersPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundMerchantOffersPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.containerId = helper.readVarInt(in);
|
this.containerId = helper.readVarInt(in);
|
||||||
|
|
||||||
int size = helper.readVarInt(in);
|
int size = helper.readVarInt(in);
|
||||||
|
@ -51,7 +49,7 @@ public class ClientboundMerchantOffersPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.containerId);
|
helper.writeVarInt(out, this.containerId);
|
||||||
|
|
||||||
helper.writeVarInt(out, this.trades.length);
|
helper.writeVarInt(out, this.trades.length);
|
||||||
|
|
|
@ -11,8 +11,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -21,7 +19,7 @@ public class ClientboundOpenScreenPacket implements MinecraftPacket {
|
||||||
private final @NonNull ContainerType type;
|
private final @NonNull ContainerType type;
|
||||||
private final @NonNull Component title;
|
private final @NonNull Component title;
|
||||||
|
|
||||||
public ClientboundOpenScreenPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundOpenScreenPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.containerId = helper.readVarInt(in);
|
this.containerId = helper.readVarInt(in);
|
||||||
this.type = ContainerType.from(helper.readVarInt(in));
|
this.type = ContainerType.from(helper.readVarInt(in));
|
||||||
this.title = helper.readComponent(in);
|
this.title = helper.readComponent(in);
|
||||||
|
@ -35,7 +33,7 @@ public class ClientboundOpenScreenPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.containerId);
|
helper.writeVarInt(out, this.containerId);
|
||||||
helper.writeVarInt(out, this.type.ordinal());
|
helper.writeVarInt(out, this.type.ordinal());
|
||||||
helper.writeComponent(out, this.title);
|
helper.writeComponent(out, this.title);
|
||||||
|
|
|
@ -12,8 +12,6 @@ import lombok.With;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -22,14 +20,14 @@ public class ClientboundBlockEntityDataPacket implements MinecraftPacket {
|
||||||
private final @NonNull BlockEntityType type;
|
private final @NonNull BlockEntityType type;
|
||||||
private final @Nullable CompoundTag nbt;
|
private final @Nullable CompoundTag nbt;
|
||||||
|
|
||||||
public ClientboundBlockEntityDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundBlockEntityDataPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.position = helper.readPosition(in);
|
this.position = helper.readPosition(in);
|
||||||
this.type = helper.readBlockEntityType(in);
|
this.type = helper.readBlockEntityType(in);
|
||||||
this.nbt = helper.readAnyTag(in);
|
this.nbt = helper.readAnyTag(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
helper.writeBlockEntityType(out, this.type);
|
helper.writeBlockEntityType(out, this.type);
|
||||||
helper.writeAnyTag(out, this.nbt);
|
helper.writeAnyTag(out, this.nbt);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ public class ClientboundExplodePacket implements MinecraftPacket {
|
||||||
private final @NonNull ExplosionInteraction blockInteraction;
|
private final @NonNull ExplosionInteraction blockInteraction;
|
||||||
private final @NonNull Sound explosionSound;
|
private final @NonNull Sound explosionSound;
|
||||||
|
|
||||||
public ClientboundExplodePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundExplodePacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.x = in.readDouble();
|
this.x = in.readDouble();
|
||||||
this.y = in.readDouble();
|
this.y = in.readDouble();
|
||||||
this.z = in.readDouble();
|
this.z = in.readDouble();
|
||||||
|
@ -54,7 +53,7 @@ public class ClientboundExplodePacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
out.writeDouble(this.x);
|
out.writeDouble(this.x);
|
||||||
out.writeDouble(this.y);
|
out.writeDouble(this.y);
|
||||||
out.writeDouble(this.z);
|
out.writeDouble(this.z);
|
||||||
|
|
|
@ -12,8 +12,6 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -25,7 +23,7 @@ public class ClientboundLevelChunkWithLightPacket implements MinecraftPacket {
|
||||||
private final @NonNull BlockEntityInfo @NonNull [] blockEntities;
|
private final @NonNull BlockEntityInfo @NonNull [] blockEntities;
|
||||||
private final @NonNull LightUpdateData lightData;
|
private final @NonNull LightUpdateData lightData;
|
||||||
|
|
||||||
public ClientboundLevelChunkWithLightPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundLevelChunkWithLightPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.x = in.readInt();
|
this.x = in.readInt();
|
||||||
this.z = in.readInt();
|
this.z = in.readInt();
|
||||||
this.heightMaps = helper.readAnyTagOrThrow(in);
|
this.heightMaps = helper.readAnyTagOrThrow(in);
|
||||||
|
@ -46,7 +44,7 @@ public class ClientboundLevelChunkWithLightPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
out.writeInt(this.x);
|
out.writeInt(this.x);
|
||||||
out.writeInt(this.z);
|
out.writeInt(this.z);
|
||||||
helper.writeAnyTag(out, this.heightMaps);
|
helper.writeAnyTag(out, this.heightMaps);
|
||||||
|
|
|
@ -10,8 +10,6 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -27,7 +25,7 @@ public class ClientboundLevelParticlesPacket implements MinecraftPacket {
|
||||||
private final float velocityOffset;
|
private final float velocityOffset;
|
||||||
private final int amount;
|
private final int amount;
|
||||||
|
|
||||||
public ClientboundLevelParticlesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundLevelParticlesPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
ParticleType type = helper.readParticleType(in);
|
ParticleType type = helper.readParticleType(in);
|
||||||
this.longDistance = in.readBoolean();
|
this.longDistance = in.readBoolean();
|
||||||
this.x = in.readDouble();
|
this.x = in.readDouble();
|
||||||
|
@ -42,7 +40,7 @@ public class ClientboundLevelParticlesPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeParticleType(out, this.particle.getType());
|
helper.writeParticleType(out, this.particle.getType());
|
||||||
out.writeBoolean(this.longDistance);
|
out.writeBoolean(this.longDistance);
|
||||||
out.writeDouble(this.x);
|
out.writeDouble(this.x);
|
||||||
|
|
|
@ -12,8 +12,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -29,7 +27,7 @@ public class ClientboundMapItemDataPacket implements MinecraftPacket {
|
||||||
this(mapId, scale, locked, icons, null);
|
this(mapId, scale, locked, icons, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundMapItemDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundMapItemDataPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.mapId = helper.readVarInt(in);
|
this.mapId = helper.readVarInt(in);
|
||||||
this.scale = in.readByte();
|
this.scale = in.readByte();
|
||||||
this.locked = in.readBoolean();
|
this.locked = in.readBoolean();
|
||||||
|
@ -64,7 +62,7 @@ public class ClientboundMapItemDataPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.mapId);
|
helper.writeVarInt(out, this.mapId);
|
||||||
out.writeByte(this.scale);
|
out.writeByte(this.scale);
|
||||||
out.writeBoolean(this.locked);
|
out.writeBoolean(this.locked);
|
||||||
|
|
|
@ -9,8 +9,6 @@ import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -18,13 +16,13 @@ public class ClientboundTagQueryPacket implements MinecraftPacket {
|
||||||
private final int transactionId;
|
private final int transactionId;
|
||||||
private final @Nullable CompoundTag nbt;
|
private final @Nullable CompoundTag nbt;
|
||||||
|
|
||||||
public ClientboundTagQueryPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundTagQueryPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.transactionId = helper.readVarInt(in);
|
this.transactionId = helper.readVarInt(in);
|
||||||
this.nbt = helper.readAnyTag(in);
|
this.nbt = helper.readAnyTag(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.transactionId);
|
helper.writeVarInt(out, this.transactionId);
|
||||||
helper.writeAnyTag(out, this.nbt);
|
helper.writeAnyTag(out, this.nbt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
public class ClientboundSetObjectivePacket implements MinecraftPacket {
|
public class ClientboundSetObjectivePacket implements MinecraftPacket {
|
||||||
|
@ -61,7 +59,7 @@ public class ClientboundSetObjectivePacket implements MinecraftPacket {
|
||||||
this.numberFormat = numberFormat;
|
this.numberFormat = numberFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundSetObjectivePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetObjectivePacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.name = helper.readString(in);
|
this.name = helper.readString(in);
|
||||||
this.action = ObjectiveAction.from(in.readByte());
|
this.action = ObjectiveAction.from(in.readByte());
|
||||||
if (this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) {
|
if (this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) {
|
||||||
|
@ -76,7 +74,7 @@ public class ClientboundSetObjectivePacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeString(out, this.name);
|
helper.writeString(out, this.name);
|
||||||
out.writeByte(this.action.ordinal());
|
out.writeByte(this.action.ordinal());
|
||||||
if (this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) {
|
if (this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import lombok.*;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -104,7 +103,7 @@ public class ClientboundSetPlayerTeamPacket implements MinecraftPacket {
|
||||||
this.players = Arrays.copyOf(players, players.length);
|
this.players = Arrays.copyOf(players, players.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundSetPlayerTeamPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetPlayerTeamPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.teamName = helper.readString(in);
|
this.teamName = helper.readString(in);
|
||||||
this.action = TeamAction.from(in.readByte());
|
this.action = TeamAction.from(in.readByte());
|
||||||
if (this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) {
|
if (this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) {
|
||||||
|
@ -141,7 +140,7 @@ public class ClientboundSetPlayerTeamPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeString(out, this.teamName);
|
helper.writeString(out, this.teamName);
|
||||||
out.writeByte(this.action.ordinal());
|
out.writeByte(this.action.ordinal());
|
||||||
if (this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) {
|
if (this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) {
|
||||||
|
|
|
@ -8,8 +8,6 @@ import lombok.*;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
@ -31,7 +29,7 @@ public class ClientboundSetScorePacket implements MinecraftPacket {
|
||||||
this.numberFormat = null;
|
this.numberFormat = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientboundSetScorePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetScorePacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.owner = helper.readString(in);
|
this.owner = helper.readString(in);
|
||||||
this.objective = helper.readString(in);
|
this.objective = helper.readString(in);
|
||||||
this.value = helper.readVarInt(in);
|
this.value = helper.readVarInt(in);
|
||||||
|
@ -40,7 +38,7 @@ public class ClientboundSetScorePacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeString(out, this.owner);
|
helper.writeString(out, this.owner);
|
||||||
helper.writeString(out, this.objective);
|
helper.writeString(out, this.objective);
|
||||||
helper.writeVarInt(out, this.value);
|
helper.writeVarInt(out, this.value);
|
||||||
|
|
|
@ -8,20 +8,18 @@ import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ClientboundSetActionBarTextPacket implements MinecraftPacket {
|
public class ClientboundSetActionBarTextPacket implements MinecraftPacket {
|
||||||
private final Component text;
|
private final Component text;
|
||||||
|
|
||||||
public ClientboundSetActionBarTextPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetActionBarTextPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.text = helper.readComponent(in);
|
this.text = helper.readComponent(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeComponent(out, this.text);
|
helper.writeComponent(out, this.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,20 +8,18 @@ import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ClientboundSetSubtitleTextPacket implements MinecraftPacket {
|
public class ClientboundSetSubtitleTextPacket implements MinecraftPacket {
|
||||||
private final Component text;
|
private final Component text;
|
||||||
|
|
||||||
public ClientboundSetSubtitleTextPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetSubtitleTextPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.text = helper.readComponent(in);
|
this.text = helper.readComponent(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeComponent(out, this.text);
|
helper.writeComponent(out, this.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,13 @@ import lombok.With;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ClientboundSetTitleTextPacket implements MinecraftPacket {
|
public class ClientboundSetTitleTextPacket implements MinecraftPacket {
|
||||||
private final @Nullable Component text;
|
private final @Nullable Component text;
|
||||||
|
|
||||||
public ClientboundSetTitleTextPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundSetTitleTextPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.text = helper.readComponent(in);
|
this.text = helper.readComponent(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
@ -23,7 +22,7 @@ public class ServerboundChatSessionUpdatePacket implements MinecraftPacket {
|
||||||
private final PublicKey publicKey;
|
private final PublicKey publicKey;
|
||||||
private final byte[] keySignature;
|
private final byte[] keySignature;
|
||||||
|
|
||||||
public ServerboundChatSessionUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ServerboundChatSessionUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.sessionId = helper.readUUID(in);
|
this.sessionId = helper.readUUID(in);
|
||||||
this.expiresAt = in.readLong();
|
this.expiresAt = in.readLong();
|
||||||
byte[] keyBytes = helper.readByteArray(in);
|
byte[] keyBytes = helper.readByteArray(in);
|
||||||
|
@ -33,7 +32,7 @@ public class ServerboundChatSessionUpdatePacket implements MinecraftPacket {
|
||||||
try {
|
try {
|
||||||
publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(keyBytes));
|
publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(keyBytes));
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
throw new IOException("Could not decode public key.", e);
|
throw new IllegalStateException("Could not decode public key.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.publicKey = publicKey;
|
this.publicKey = publicKey;
|
||||||
|
|
|
@ -20,7 +20,6 @@ import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -60,7 +59,7 @@ public class ServerboundContainerClickPacket implements MinecraftPacket {
|
||||||
this.changedSlots = changedSlots;
|
this.changedSlots = changedSlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerboundContainerClickPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ServerboundContainerClickPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.containerId = in.readByte();
|
this.containerId = in.readByte();
|
||||||
this.stateId = helper.readVarInt(in);
|
this.stateId = helper.readVarInt(in);
|
||||||
this.slot = in.readShort();
|
this.slot = in.readShort();
|
||||||
|
@ -96,7 +95,7 @@ public class ServerboundContainerClickPacket implements MinecraftPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
out.writeByte(this.containerId);
|
out.writeByte(this.containerId);
|
||||||
helper.writeVarInt(out, this.stateId);
|
helper.writeVarInt(out, this.stateId);
|
||||||
out.writeShort(this.slot);
|
out.writeShort(this.slot);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
|
@ -40,23 +40,22 @@ public class ServerboundSeenAdvancementsPacket implements MinecraftPacket {
|
||||||
return this.tabId;
|
return this.tabId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerboundSeenAdvancementsPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ServerboundSeenAdvancementsPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.action = AdvancementTabAction.from(helper.readVarInt(in));
|
this.action = AdvancementTabAction.from(helper.readVarInt(in));
|
||||||
switch (this.action) {
|
this.tabId = switch (this.action) {
|
||||||
case CLOSED_SCREEN -> this.tabId = null;
|
case CLOSED_SCREEN -> null;
|
||||||
case OPENED_TAB -> this.tabId = helper.readString(in);
|
case OPENED_TAB -> helper.readString(in);
|
||||||
default -> throw new IOException("Unknown advancement tab action: " + this.action);
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
helper.writeVarInt(out, this.action.ordinal());
|
helper.writeVarInt(out, this.action.ordinal());
|
||||||
switch (this.action) {
|
Consumer<String> tabIdWriter = switch (this.action) {
|
||||||
case CLOSED_SCREEN -> {
|
case CLOSED_SCREEN -> tabId -> {
|
||||||
}
|
};
|
||||||
case OPENED_TAB -> helper.writeString(out, this.tabId);
|
case OPENED_TAB -> tabId -> helper.writeString(out, tabId);
|
||||||
default -> throw new IOException("Unknown advancement tab action: " + this.action);
|
};
|
||||||
}
|
tabIdWriter.accept(this.tabId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,9 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ItemStack;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@With
|
@With
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -19,13 +16,13 @@ public class ServerboundSetCreativeModeSlotPacket implements MinecraftPacket {
|
||||||
private final int slot;
|
private final int slot;
|
||||||
private final @Nullable ItemStack clickedItem;
|
private final @Nullable ItemStack clickedItem;
|
||||||
|
|
||||||
public ServerboundSetCreativeModeSlotPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ServerboundSetCreativeModeSlotPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.slot = in.readShort();
|
this.slot = in.readShort();
|
||||||
this.clickedItem = helper.readItemStack(in);
|
this.clickedItem = helper.readItemStack(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||||
out.writeShort(this.slot);
|
out.writeShort(this.slot);
|
||||||
helper.writeItemStack(out, this.clickedItem);
|
helper.writeItemStack(out, this.clickedItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.With;
|
import lombok.With;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
@ -22,7 +21,7 @@ public class ClientboundHelloPacket implements MinecraftPacket {
|
||||||
private final @NonNull PublicKey publicKey;
|
private final @NonNull PublicKey publicKey;
|
||||||
private final byte @NonNull [] challenge;
|
private final byte @NonNull [] challenge;
|
||||||
|
|
||||||
public ClientboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
public ClientboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||||
this.serverId = helper.readString(in);
|
this.serverId = helper.readString(in);
|
||||||
byte[] publicKey = helper.readByteArray(in);
|
byte[] publicKey = helper.readByteArray(in);
|
||||||
this.challenge = helper.readByteArray(in);
|
this.challenge = helper.readByteArray(in);
|
||||||
|
@ -30,7 +29,7 @@ public class ClientboundHelloPacket implements MinecraftPacket {
|
||||||
try {
|
try {
|
||||||
this.publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKey));
|
this.publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKey));
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
throw new IOException("Could not decode public key.", e);
|
throw new IllegalStateException("Could not decode public key.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@ import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -38,7 +36,7 @@ public class ChunkTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChunkSectionEncoding() throws IOException {
|
public void testChunkSectionEncoding() {
|
||||||
MinecraftCodecHelper helper = new MinecraftCodecHelper(Int2ObjectMaps.emptyMap(), Collections.emptyMap());
|
MinecraftCodecHelper helper = new MinecraftCodecHelper(Int2ObjectMaps.emptyMap(), Collections.emptyMap());
|
||||||
for (ChunkSection section : chunkSectionsToTest) {
|
for (ChunkSection section : chunkSectionsToTest) {
|
||||||
ByteBuf buf = Unpooled.buffer();
|
ByteBuf buf = Unpooled.buffer();
|
Loading…
Add table
Add a link
Reference in a new issue