Merge 1.18 Update
Merge pull request #577 from Xernium/future/1.18: [Future] Support for Minecraft 1.18
This commit is contained in:
@@ -55,7 +55,8 @@ public enum ProtocolVersion {
|
|||||||
MINECRAFT_1_16_3(753, "1.16.3"),
|
MINECRAFT_1_16_3(753, "1.16.3"),
|
||||||
MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"),
|
MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"),
|
||||||
MINECRAFT_1_17(755, "1.17"),
|
MINECRAFT_1_17(755, "1.17"),
|
||||||
MINECRAFT_1_17_1(756, "1.17.1");
|
MINECRAFT_1_17_1(756, "1.17.1"),
|
||||||
|
MINECRAFT_1_18(757, "1.18");
|
||||||
|
|
||||||
private static final int SNAPSHOT_BIT = 30;
|
private static final int SNAPSHOT_BIT = 30;
|
||||||
|
|
||||||
|
@@ -57,6 +57,16 @@ public interface PlayerSettings {
|
|||||||
*/
|
*/
|
||||||
MainHand getMainHand();
|
MainHand getMainHand();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the client explicitly allows listing on the
|
||||||
|
* {@link com.velocitypowered.api.proxy.player.TabList} or not in
|
||||||
|
* anonymous TabList mode.
|
||||||
|
* This feature was introduced in 1.18.
|
||||||
|
*
|
||||||
|
* @return whether or not the client explicitly allows listing. Always false on older clients.
|
||||||
|
*/
|
||||||
|
boolean isClientListingAllowed();
|
||||||
|
|
||||||
enum ChatMode {
|
enum ChatMode {
|
||||||
SHOWN,
|
SHOWN,
|
||||||
COMMANDS_ONLY,
|
COMMANDS_ONLY,
|
||||||
|
@@ -26,7 +26,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
public class ClientSettingsWrapper implements PlayerSettings {
|
public class ClientSettingsWrapper implements PlayerSettings {
|
||||||
|
|
||||||
static final PlayerSettings DEFAULT = new ClientSettingsWrapper(
|
static final PlayerSettings DEFAULT = new ClientSettingsWrapper(
|
||||||
new ClientSettings("en_US", (byte) 10, 0, true, (short) 127, 1, true));
|
new ClientSettings("en_US", (byte) 10, 0, true, (short) 127, 1, true, false));
|
||||||
|
|
||||||
private final ClientSettings settings;
|
private final ClientSettings settings;
|
||||||
private final SkinParts parts;
|
private final SkinParts parts;
|
||||||
@@ -74,5 +74,9 @@ public class ClientSettingsWrapper implements PlayerSettings {
|
|||||||
return settings.getMainHand() == 1 ? MainHand.RIGHT : MainHand.LEFT;
|
return settings.getMainHand() == 1 ? MainHand.RIGHT : MainHand.LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isClientListingAllowed() {
|
||||||
|
return settings.isClientListingAllowed();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16;
|
|||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16_2;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16_2;
|
||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16_4;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16_4;
|
||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_17;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_17;
|
||||||
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_18;
|
||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_7_2;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_7_2;
|
||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
|
||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9;
|
||||||
@@ -246,7 +247,8 @@ public enum StateRegistry {
|
|||||||
map(0x53, MINECRAFT_1_14, true),
|
map(0x53, MINECRAFT_1_14, true),
|
||||||
map(0x54, MINECRAFT_1_15, true),
|
map(0x54, MINECRAFT_1_15, true),
|
||||||
map(0x53, MINECRAFT_1_16, true),
|
map(0x53, MINECRAFT_1_16, true),
|
||||||
map(0x5E, MINECRAFT_1_17, true));
|
map(0x5E, MINECRAFT_1_17, true),
|
||||||
|
map(0x5F, MINECRAFT_1_18, true));
|
||||||
clientbound.register(LegacyTitlePacket.class, LegacyTitlePacket::new,
|
clientbound.register(LegacyTitlePacket.class, LegacyTitlePacket::new,
|
||||||
map(0x45, MINECRAFT_1_8, true),
|
map(0x45, MINECRAFT_1_8, true),
|
||||||
map(0x45, MINECRAFT_1_9, true),
|
map(0x45, MINECRAFT_1_9, true),
|
||||||
@@ -257,13 +259,16 @@ public enum StateRegistry {
|
|||||||
map(0x50, MINECRAFT_1_15, true),
|
map(0x50, MINECRAFT_1_15, true),
|
||||||
map(0x4F, MINECRAFT_1_16, MINECRAFT_1_16_4, true));
|
map(0x4F, MINECRAFT_1_16, MINECRAFT_1_16_4, true));
|
||||||
clientbound.register(TitleSubtitlePacket.class, TitleSubtitlePacket::new,
|
clientbound.register(TitleSubtitlePacket.class, TitleSubtitlePacket::new,
|
||||||
map(0x57, MINECRAFT_1_17, true));
|
map(0x57, MINECRAFT_1_17, true),
|
||||||
|
map(0x58, MINECRAFT_1_18, true));
|
||||||
clientbound.register(TitleTextPacket.class, TitleTextPacket::new,
|
clientbound.register(TitleTextPacket.class, TitleTextPacket::new,
|
||||||
map(0x59, MINECRAFT_1_17, true));
|
map(0x59, MINECRAFT_1_17, true),
|
||||||
|
map(0x5A, MINECRAFT_1_18, true));
|
||||||
clientbound.register(TitleActionbarPacket.class, TitleActionbarPacket::new,
|
clientbound.register(TitleActionbarPacket.class, TitleActionbarPacket::new,
|
||||||
map(0x41, MINECRAFT_1_17, true));
|
map(0x41, MINECRAFT_1_17, true));
|
||||||
clientbound.register(TitleTimesPacket.class, TitleTimesPacket::new,
|
clientbound.register(TitleTimesPacket.class, TitleTimesPacket::new,
|
||||||
map(0x5A, MINECRAFT_1_17, true));
|
map(0x5A, MINECRAFT_1_17, true),
|
||||||
|
map(0x5B, MINECRAFT_1_18, true));
|
||||||
clientbound.register(TitleClearPacket.class, TitleClearPacket::new,
|
clientbound.register(TitleClearPacket.class, TitleClearPacket::new,
|
||||||
map(0x10, MINECRAFT_1_17, true));
|
map(0x10, MINECRAFT_1_17, true));
|
||||||
clientbound.register(PlayerListItem.class, PlayerListItem::new,
|
clientbound.register(PlayerListItem.class, PlayerListItem::new,
|
||||||
|
@@ -34,18 +34,20 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
private short skinParts;
|
private short skinParts;
|
||||||
private int mainHand;
|
private int mainHand;
|
||||||
private boolean chatFilteringEnabled; // Added in 1.17
|
private boolean chatFilteringEnabled; // Added in 1.17
|
||||||
|
private boolean clientListingAllowed; // Added in 1.18, overwrites server-list "anonymous" mode
|
||||||
|
|
||||||
public ClientSettings() {
|
public ClientSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientSettings(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
|
public ClientSettings(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
|
||||||
short skinParts, int mainHand, boolean chatFilteringEnabled) {
|
short skinParts, int mainHand, boolean chatFilteringEnabled, boolean clientListingAllowed) {
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.viewDistance = viewDistance;
|
this.viewDistance = viewDistance;
|
||||||
this.chatVisibility = chatVisibility;
|
this.chatVisibility = chatVisibility;
|
||||||
this.chatColors = chatColors;
|
this.chatColors = chatColors;
|
||||||
this.skinParts = skinParts;
|
this.skinParts = skinParts;
|
||||||
this.mainHand = mainHand;
|
this.mainHand = mainHand;
|
||||||
|
this.clientListingAllowed = clientListingAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocale() {
|
public String getLocale() {
|
||||||
@@ -107,6 +109,14 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
this.chatFilteringEnabled = chatFilteringEnabled;
|
this.chatFilteringEnabled = chatFilteringEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isClientListingAllowed() {
|
||||||
|
return clientListingAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientListingAllowed(boolean clientListingAllowed) {
|
||||||
|
this.clientListingAllowed = clientListingAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ClientSettings{"
|
return "ClientSettings{"
|
||||||
@@ -117,6 +127,7 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
+ ", skinParts=" + skinParts
|
+ ", skinParts=" + skinParts
|
||||||
+ ", mainHand=" + mainHand
|
+ ", mainHand=" + mainHand
|
||||||
+ ", chatFilteringEnabled=" + chatFilteringEnabled
|
+ ", chatFilteringEnabled=" + chatFilteringEnabled
|
||||||
|
+ ", clientListingAllowed=" + clientListingAllowed
|
||||||
+ '}';
|
+ '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +149,10 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
|
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) {
|
||||||
this.chatFilteringEnabled = buf.readBoolean();
|
this.chatFilteringEnabled = buf.readBoolean();
|
||||||
|
|
||||||
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) {
|
||||||
|
this.clientListingAllowed = buf.readBoolean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,6 +178,10 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
|
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) {
|
||||||
buf.writeBoolean(chatFilteringEnabled);
|
buf.writeBoolean(chatFilteringEnabled);
|
||||||
|
|
||||||
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) {
|
||||||
|
buf.writeBoolean(clientListingAllowed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
private DimensionData currentDimensionData; // 1.16.2+
|
private DimensionData currentDimensionData; // 1.16.2+
|
||||||
private short previousGamemode; // 1.16+
|
private short previousGamemode; // 1.16+
|
||||||
private CompoundBinaryTag biomeRegistry; // 1.16.2+
|
private CompoundBinaryTag biomeRegistry; // 1.16.2+
|
||||||
|
private int simulationDistance; // 1.18+
|
||||||
|
|
||||||
public int getEntityId() {
|
public int getEntityId() {
|
||||||
return entityId;
|
return entityId;
|
||||||
@@ -163,6 +164,14 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
return currentDimensionData;
|
return currentDimensionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSimulationDistance(){
|
||||||
|
return simulationDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulationDistance(int simulationDistance) {
|
||||||
|
this.simulationDistance = simulationDistance;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "JoinGame{"
|
return "JoinGame{"
|
||||||
@@ -178,6 +187,7 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
+ ", dimensionRegistry='" + dimensionRegistry + '\''
|
+ ", dimensionRegistry='" + dimensionRegistry + '\''
|
||||||
+ ", dimensionInfo='" + dimensionInfo + '\''
|
+ ", dimensionInfo='" + dimensionInfo + '\''
|
||||||
+ ", previousGamemode=" + previousGamemode
|
+ ", previousGamemode=" + previousGamemode
|
||||||
|
+ ", simulationDistance=" + simulationDistance
|
||||||
+ '}';
|
+ '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,6 +281,10 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.viewDistance = ProtocolUtils.readVarInt(buf);
|
this.viewDistance = ProtocolUtils.readVarInt(buf);
|
||||||
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) {
|
||||||
|
this.simulationDistance = ProtocolUtils.readVarInt(buf);
|
||||||
|
}
|
||||||
|
|
||||||
this.reducedDebugInfo = buf.readBoolean();
|
this.reducedDebugInfo = buf.readBoolean();
|
||||||
this.showRespawnScreen = buf.readBoolean();
|
this.showRespawnScreen = buf.readBoolean();
|
||||||
boolean isDebug = buf.readBoolean();
|
boolean isDebug = buf.readBoolean();
|
||||||
@@ -360,6 +374,10 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
buf.writeByte(maxPlayers);
|
buf.writeByte(maxPlayers);
|
||||||
}
|
}
|
||||||
ProtocolUtils.writeVarInt(buf, viewDistance);
|
ProtocolUtils.writeVarInt(buf, viewDistance);
|
||||||
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) {
|
||||||
|
ProtocolUtils.writeVarInt(buf, simulationDistance);
|
||||||
|
}
|
||||||
|
|
||||||
buf.writeBoolean(reducedDebugInfo);
|
buf.writeBoolean(reducedDebugInfo);
|
||||||
buf.writeBoolean(showRespawnScreen);
|
buf.writeBoolean(showRespawnScreen);
|
||||||
buf.writeBoolean(dimensionInfo.isDebugType());
|
buf.writeBoolean(dimensionInfo.isDebugType());
|
||||||
|
Reference in New Issue
Block a user