Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.19.1 #702

Merged
merged 10 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>1.19-SNAPSHOT</version>
<version>1.19.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>MCProtocolLib</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void packetSent(Session session, Packet packet) {

if (this.targetState == ProtocolState.LOGIN) {
GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
session.send(new ServerboundHelloPacket(profile.getName(), null, null, null));
session.send(new ServerboundHelloPacket(profile.getName(), null, null, null, profile.getId()));
} else {
session.send(new ServerboundStatusRequestPacket());
}
Expand Down
274 changes: 141 additions & 133 deletions src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodec.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,17 @@ public void writeRecipeIngredient(ByteBuf buf, Ingredient ingredient) throws IOE
}

public DataPalette readDataPalette(ByteBuf buf, PaletteType paletteType, int globalPaletteBits) throws IOException {
int bitsPerEntry = buf.readByte();
int bitsPerEntry = buf.readByte() & 0xFF;
Palette palette = this.readPalette(buf, paletteType, bitsPerEntry);
BitStorage storage;
if (!(palette instanceof SingletonPalette)) {
storage = new BitStorage(bitsPerEntry, paletteType.getStorageSize(), this.readLongArray(buf));
} else {
this.readVarInt(buf);
// Eat up - can be seen on Hypixel as of 1.19.0
int length = this.readVarInt(buf);
for (int i = 0; i < length; i++) {
buf.readLong();
}
storage = null;
}

Expand Down Expand Up @@ -649,18 +653,15 @@ public void writeDataPalette(ByteBuf buf, DataPalette palette) {
}

private Palette readPalette(ByteBuf buf, PaletteType paletteType, int bitsPerEntry) throws IOException {
if (bitsPerEntry > paletteType.getMaxBitsPerEntry()) {
return new GlobalPalette();
}

if (bitsPerEntry == 0) {
return new SingletonPalette(this.readVarInt(buf));
}

if (bitsPerEntry <= paletteType.getMinBitsPerEntry()) {
return new ListPalette(bitsPerEntry, buf, this);
} else {
} else if (bitsPerEntry <= paletteType.getMaxBitsPerEntry()) {
return new MapPalette(bitsPerEntry, buf, this);
} else {
return GlobalPalette.INSTANCE;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.steveice10.mc.protocol.data.game;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class ArgumentSignature {
private final String name;
private final byte[] signature;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

public enum BuiltinChatType {
CHAT,
SYSTEM,
GAME_INFO,
SAY_COMMAND,
MSG_COMMAND,
TEAM_MSG_COMMAND,
EMOTE_COMMAND,
TELLRAW_COMMAND;
MSG_COMMAND_INCOMING,
MSG_COMMAND_OUTGOING,
TEAM_MSG_COMMAND_INCOMING,
TEAM_MSG_COMMAND_OUTGOING,
EMOTE_COMMAND;

private final String resourceLocation;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.steveice10.mc.protocol.data.game;

public enum ChatCompletionAction {
ADD,
REMOVE,
SET;

public static final ChatCompletionAction[] VALUES = values();

public static ChatCompletionAction from(int id) {
return VALUES[id];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.steveice10.mc.protocol.data.game;

public enum ChatFilterType {
PASS_THROUGH,
FULLY_FILTERED,
PARTIALLY_FILTERED;

public static final ChatFilterType[] VALUES = values();

public static ChatFilterType from(int id) {
return VALUES[id];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.steveice10.mc.protocol.data.game;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.UUID;

@Data
@AllArgsConstructor
public class LastSeenMessage {
private final UUID profileId;
private final byte[] lastSignature;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;

@EqualsAndHashCode
public class BitStorage {
Expand Down Expand Up @@ -30,7 +33,7 @@ public class BitStorage {
};

@Getter
private final @NonNull long[] data;
private final long @NonNull[] data;
@Getter
private final int bitsPerEntry;
@Getter
Expand All @@ -46,7 +49,7 @@ public BitStorage(int bitsPerEntry, int size) {
this(bitsPerEntry, size, null);
}

public BitStorage(int bitsPerEntry, int size, long[] data) {
public BitStorage(int bitsPerEntry, int size, long @Nullable[] data) {
if (bitsPerEntry < 1 || bitsPerEntry > 32) {
throw new IllegalArgumentException("bitsPerEntry must be between 1 and 32, inclusive.");
}
Expand All @@ -59,7 +62,8 @@ public BitStorage(int bitsPerEntry, int size, long[] data) {
int expectedLength = (size + this.valuesPerLong - 1) / this.valuesPerLong;
if (data != null) {
if (data.length != expectedLength) {
throw new IllegalArgumentException("Expected " + expectedLength + " longs but got " + data.length + " longs");
// Hypixel as of 1.19.0
data = Arrays.copyOf(data, expectedLength);
}

this.data = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
@EqualsAndHashCode
public class GlobalPalette implements Palette {
public static final GlobalPalette INSTANCE = new GlobalPalette();

@Override
public int size() {
return Integer.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public ClientboundChatPreviewPacket(ByteBuf in, MinecraftCodecHelper helper) thr
@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
out.writeInt(this.queryId);
out.writeBoolean(this.preview != null);
if (this.preview != null) {
helper.writeString(out, DefaultComponentSerializer.get().serialize(this.preview));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.steveice10.mc.protocol.packet.ingame.clientbound;

import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.data.game.ChatCompletionAction;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.With;

@Data
@With
@AllArgsConstructor
public class ClientboundCustomChatCompletionsPacket implements MinecraftPacket {
private final ChatCompletionAction action;
private final String[] entries;

public ClientboundCustomChatCompletionsPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.action = ChatCompletionAction.from(helper.readVarInt(in));
this.entries = new String[helper.readVarInt(in)];
for (int i = 0; i < this.entries.length; i++) {
this.entries[i] = helper.readString(in);
}
}

@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.action.ordinal());
helper.writeVarInt(out, this.entries.length);
for (String entry : this.entries) {
helper.writeString(out, entry);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.steveice10.mc.protocol.packet.ingame.clientbound;

import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.With;

import java.io.IOException;

@Data
@With
@AllArgsConstructor
public class ClientboundDeleteChatPacket implements MinecraftPacket {
private final byte[] messageSignature;

public ClientboundDeleteChatPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.messageSignature = helper.readByteArray(in);
}

@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writeVarInt(out, this.messageSignature.length);
out.writeBytes(this.messageSignature);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.github.steveice10.mc.protocol.packet.ingame.clientbound;

import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.With;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.UUID;

@Data
@With
@AllArgsConstructor
public class ClientboundPlayerChatHeaderPacket implements MinecraftPacket {
private final byte @Nullable[] previousSignature;
private final UUID sender;
private final byte[] headerSignature;
private final byte[] bodyDigest;

public ClientboundPlayerChatHeaderPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
if (in.readBoolean()) {
this.previousSignature = helper.readByteArray(in);
} else {
this.previousSignature = null;
}

this.sender = helper.readUUID(in);
this.headerSignature = helper.readByteArray(in);
this.bodyDigest = helper.readByteArray(in);
}

@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
if (this.previousSignature != null) {
out.writeBoolean(true);
helper.writeVarInt(out, previousSignature.length);
out.writeBytes(this.previousSignature);
} else {
out.writeBoolean(false);
}

helper.writeUUID(out, this.sender);
helper.writeVarInt(out, this.headerSignature.length);
out.writeBytes(this.headerSignature);
helper.writeVarInt(out, this.bodyDigest.length);
out.writeBytes(this.bodyDigest);
}
}
Loading