3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-29 14:40:21 +02:00
Dieser Commit ist enthalten in:
Five (Xer) 2020-07-12 14:36:28 +02:00
Ursprung 4ba8996fed
Commit c8aeac455b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F306B10E6330E7
4 geänderte Dateien mit 59 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -37,7 +37,7 @@ public enum ProtocolVersion {
MINECRAFT_1_15_2(578, "1.15.2"), MINECRAFT_1_15_2(578, "1.15.2"),
MINECRAFT_1_16(735, "1.16"), MINECRAFT_1_16(735, "1.16"),
MINECRAFT_1_16_1(736, "1.16.1"), MINECRAFT_1_16_1(736, "1.16.1"),
MINECRAFT_1_16_2(738, "1.16.2"); MINECRAFT_1_16_2(740, "1.16.2");
private final int protocol; private final int protocol;
private final String name; private final String name;

Datei anzeigen

@ -79,27 +79,22 @@ public final class DimensionRegistry {
* Encodes the stored Dimension registry as CompoundTag. * Encodes the stored Dimension registry as CompoundTag.
* @return the CompoundTag containing identifier:type mappings * @return the CompoundTag containing identifier:type mappings
*/ */
public CompoundTag encodeRegistry() { public ListTag encodeRegistry() {
CompoundTag ret = new CompoundTag();
ListTag list = new ListTag(TagType.COMPOUND); ListTag list = new ListTag(TagType.COMPOUND);
for (DimensionData iter : registeredDimensions.values()) { for (DimensionData iter : registeredDimensions.values()) {
list.add(iter.encodeAsCompundTag()); list.add(iter.encodeAsCompundTag());
} }
ret.put("dimension", list); return list;
return ret;
} }
/** /**
* Decodes a CompoundTag storing a dimension registry. * Decodes a CompoundTag storing a dimension registry.
* @param toParse CompoundTag containing a dimension registry * @param toParse CompoundTag containing a dimension registry
*/ */
public static ImmutableSet<DimensionData> fromGameData(CompoundTag toParse) { public static ImmutableSet<DimensionData> fromGameData(ListTag toParse) {
Preconditions.checkNotNull(toParse, "CompoundTag cannot be null"); Preconditions.checkNotNull(toParse, "ListTag cannot be null");
Preconditions.checkArgument(toParse.contains("dimension", TagType.LIST),
"CompoundTag does not contain a dimension list");
ListTag dimensions = toParse.getList("dimension");
ImmutableSet.Builder<DimensionData> mappings = ImmutableSet.builder(); ImmutableSet.Builder<DimensionData> mappings = ImmutableSet.builder();
for (Tag iter : dimensions) { for (Tag iter : toParse) {
if (iter instanceof CompoundTag) { if (iter instanceof CompoundTag) {
mappings.add(DimensionData.decodeCompoundTag((CompoundTag) iter)); mappings.add(DimensionData.decodeCompoundTag((CompoundTag) iter));
} }

Datei anzeigen

@ -141,39 +141,45 @@ public enum StateRegistry {
map(0x0E, MINECRAFT_1_9, false), map(0x0E, MINECRAFT_1_9, false),
map(0x10, MINECRAFT_1_13, false), map(0x10, MINECRAFT_1_13, false),
map(0x11, MINECRAFT_1_15, false), map(0x11, MINECRAFT_1_15, false),
map(0x10, MINECRAFT_1_16, false)); map(0x10, MINECRAFT_1_16, false),
map(0x0F, MINECRAFT_1_16_2, false));
clientbound.register(AvailableCommands.class, AvailableCommands::new, clientbound.register(AvailableCommands.class, AvailableCommands::new,
map(0x11, MINECRAFT_1_13, false), map(0x11, MINECRAFT_1_13, false),
map(0x12, MINECRAFT_1_15, false), map(0x12, MINECRAFT_1_15, false),
map(0x11, MINECRAFT_1_16, false)); map(0x11, MINECRAFT_1_16, false),
map(0x10, MINECRAFT_1_16_2, false));
clientbound.register(PluginMessage.class, PluginMessage::new, clientbound.register(PluginMessage.class, PluginMessage::new,
map(0x3F, MINECRAFT_1_8, false), map(0x3F, MINECRAFT_1_8, false),
map(0x18, MINECRAFT_1_9, false), map(0x18, MINECRAFT_1_9, false),
map(0x19, MINECRAFT_1_13, false), map(0x19, MINECRAFT_1_13, false),
map(0x18, MINECRAFT_1_14, false), map(0x18, MINECRAFT_1_14, false),
map(0x19, MINECRAFT_1_15, false), map(0x19, MINECRAFT_1_15, false),
map(0x18, MINECRAFT_1_16, false)); map(0x18, MINECRAFT_1_16, false),
map(0x17, MINECRAFT_1_16_2, false));
clientbound.register(Disconnect.class, Disconnect::new, clientbound.register(Disconnect.class, Disconnect::new,
map(0x40, MINECRAFT_1_8, false), map(0x40, MINECRAFT_1_8, false),
map(0x1A, MINECRAFT_1_9, false), map(0x1A, MINECRAFT_1_9, false),
map(0x1B, MINECRAFT_1_13, false), map(0x1B, MINECRAFT_1_13, false),
map(0x1A, MINECRAFT_1_14, false), map(0x1A, MINECRAFT_1_14, false),
map(0x1B, MINECRAFT_1_15, false), map(0x1B, MINECRAFT_1_15, false),
map(0x1A, MINECRAFT_1_16, false)); map(0x1A, MINECRAFT_1_16, false),
map(0x19, MINECRAFT_1_16_2, false));
clientbound.register(KeepAlive.class, KeepAlive::new, clientbound.register(KeepAlive.class, KeepAlive::new,
map(0x00, MINECRAFT_1_8, false), map(0x00, MINECRAFT_1_8, false),
map(0x1F, MINECRAFT_1_9, false), map(0x1F, MINECRAFT_1_9, false),
map(0x21, MINECRAFT_1_13, false), map(0x21, MINECRAFT_1_13, false),
map(0x20, MINECRAFT_1_14, false), map(0x20, MINECRAFT_1_14, false),
map(0x21, MINECRAFT_1_15, false), map(0x21, MINECRAFT_1_15, false),
map(0x20, MINECRAFT_1_16, false)); map(0x20, MINECRAFT_1_16, false),
map(0x1F, MINECRAFT_1_16_2, false));
clientbound.register(JoinGame.class, JoinGame::new, clientbound.register(JoinGame.class, JoinGame::new,
map(0x01, MINECRAFT_1_8, false), map(0x01, MINECRAFT_1_8, false),
map(0x23, MINECRAFT_1_9, false), map(0x23, MINECRAFT_1_9, false),
map(0x25, MINECRAFT_1_13, false), map(0x25, MINECRAFT_1_13, false),
map(0x25, MINECRAFT_1_14, false), map(0x25, MINECRAFT_1_14, false),
map(0x26, MINECRAFT_1_15, false), map(0x26, MINECRAFT_1_15, false),
map(0x25, MINECRAFT_1_16, false)); map(0x25, MINECRAFT_1_16, false),
map(0x24, MINECRAFT_1_16_2, false));
clientbound.register(Respawn.class, Respawn::new, clientbound.register(Respawn.class, Respawn::new,
map(0x07, MINECRAFT_1_8, true), map(0x07, MINECRAFT_1_8, true),
map(0x33, MINECRAFT_1_9, true), map(0x33, MINECRAFT_1_9, true),
@ -182,7 +188,8 @@ public enum StateRegistry {
map(0x38, MINECRAFT_1_13, true), map(0x38, MINECRAFT_1_13, true),
map(0x3A, MINECRAFT_1_14, true), map(0x3A, MINECRAFT_1_14, true),
map(0x3B, MINECRAFT_1_15, true), map(0x3B, MINECRAFT_1_15, true),
map(0x3A, MINECRAFT_1_16, true)); map(0x3A, MINECRAFT_1_16, true),
map(0x39, MINECRAFT_1_16_2, true));
clientbound.register(ResourcePackRequest.class, ResourcePackRequest::new, clientbound.register(ResourcePackRequest.class, ResourcePackRequest::new,
map(0x48, MINECRAFT_1_8, true), map(0x48, MINECRAFT_1_8, true),
map(0x32, MINECRAFT_1_9, true), map(0x32, MINECRAFT_1_9, true),
@ -191,7 +198,8 @@ public enum StateRegistry {
map(0x37, MINECRAFT_1_13, true), map(0x37, MINECRAFT_1_13, true),
map(0x39, MINECRAFT_1_14, true), map(0x39, MINECRAFT_1_14, true),
map(0x3A, MINECRAFT_1_15, true), map(0x3A, MINECRAFT_1_15, true),
map(0x39, MINECRAFT_1_16, true)); map(0x39, MINECRAFT_1_16, true),
map(0x38, MINECRAFT_1_16_2, true));
clientbound.register(HeaderAndFooter.class, HeaderAndFooter::new, clientbound.register(HeaderAndFooter.class, HeaderAndFooter::new,
map(0x47, MINECRAFT_1_8, true), map(0x47, MINECRAFT_1_8, true),
map(0x48, MINECRAFT_1_9, true), map(0x48, MINECRAFT_1_9, true),
@ -218,7 +226,8 @@ public enum StateRegistry {
map(0x30, MINECRAFT_1_13, false), map(0x30, MINECRAFT_1_13, false),
map(0x33, MINECRAFT_1_14, false), map(0x33, MINECRAFT_1_14, false),
map(0x34, MINECRAFT_1_15, false), map(0x34, MINECRAFT_1_15, false),
map(0x33, MINECRAFT_1_16, false)); map(0x33, MINECRAFT_1_16, false),
map(0x32, MINECRAFT_1_16_2, false));
} }
}, },
LOGIN { LOGIN {

Datei anzeigen

@ -8,6 +8,9 @@ import com.velocitypowered.proxy.connection.registry.DimensionInfo;
import com.velocitypowered.proxy.connection.registry.DimensionRegistry; import com.velocitypowered.proxy.connection.registry.DimensionRegistry;
import com.velocitypowered.proxy.protocol.*; import com.velocitypowered.proxy.protocol.*;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.kyori.nbt.CompoundTag;
import net.kyori.nbt.ListTag;
import net.kyori.nbt.TagType;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public class JoinGame implements MinecraftPacket { public class JoinGame implements MinecraftPacket {
@ -26,6 +29,7 @@ public class JoinGame implements MinecraftPacket {
private DimensionRegistry dimensionRegistry; // 1.16+ private DimensionRegistry dimensionRegistry; // 1.16+
private DimensionInfo dimensionInfo; // 1.16+ private DimensionInfo dimensionInfo; // 1.16+
private short previousGamemode; // 1.16+ private short previousGamemode; // 1.16+
private CompoundTag biomeRegistry; // 1.16.2+
public int getEntityId() { public int getEntityId() {
return entityId; return entityId;
@ -127,6 +131,14 @@ public class JoinGame implements MinecraftPacket {
this.isHardcore = isHardcore; this.isHardcore = isHardcore;
} }
public CompoundTag getBiomeRegistry() {
return biomeRegistry;
}
public void setBiomeRegistry(CompoundTag biomeRegistry) {
this.biomeRegistry = biomeRegistry;
}
@Override @Override
public String toString() { public String toString() {
return "JoinGame{" return "JoinGame{"
@ -162,7 +174,17 @@ public class JoinGame implements MinecraftPacket {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
this.previousGamemode = buf.readByte(); this.previousGamemode = buf.readByte();
ImmutableSet<String> levelNames = ImmutableSet.copyOf(ProtocolUtils.readStringArray(buf)); ImmutableSet<String> levelNames = ImmutableSet.copyOf(ProtocolUtils.readStringArray(buf));
ImmutableSet<DimensionData> readData = DimensionRegistry.fromGameData(ProtocolUtils.readCompoundTag(buf)); CompoundTag registryContainer = ProtocolUtils.readCompoundTag(buf);
ListTag dimensionRegistryContainer = null;
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
dimensionRegistryContainer = registryContainer.getCompound("minecraft:dimension_type")
.getList("value", TagType.COMPOUND);
this.biomeRegistry = registryContainer.getCompound("minecraft:worldgen/biome");
} else {
dimensionRegistryContainer = registryContainer.getList("dimension", TagType.COMPOUND);
}
ImmutableSet<DimensionData> readData =
DimensionRegistry.fromGameData(dimensionRegistryContainer);
this.dimensionRegistry = new DimensionRegistry(readData, levelNames); this.dimensionRegistry = new DimensionRegistry(readData, levelNames);
dimensionIdentifier = ProtocolUtils.readString(buf); dimensionIdentifier = ProtocolUtils.readString(buf);
levelName = ProtocolUtils.readString(buf); levelName = ProtocolUtils.readString(buf);
@ -212,7 +234,18 @@ public class JoinGame implements MinecraftPacket {
buf.writeByte(previousGamemode); buf.writeByte(previousGamemode);
ProtocolUtils.writeStringArray(buf, dimensionRegistry.getLevelNames().toArray( ProtocolUtils.writeStringArray(buf, dimensionRegistry.getLevelNames().toArray(
new String[dimensionRegistry.getLevelNames().size()])); new String[dimensionRegistry.getLevelNames().size()]));
ProtocolUtils.writeCompoundTag(buf, dimensionRegistry.encodeRegistry()); CompoundTag registryContainer = new CompoundTag();
ListTag encodedDimensionRegistry = dimensionRegistry.encodeRegistry();
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
CompoundTag dimensionRegistryDummy = new CompoundTag();
dimensionRegistryDummy.putString("type", "minecraft:dimension_type");
dimensionRegistryDummy.put("value", encodedDimensionRegistry);
registryContainer.put("minecraft:dimension_type", dimensionRegistryDummy);
registryContainer.put("minecraft:worldgen/biome", biomeRegistry);
} else {
registryContainer.put("dimension", encodedDimensionRegistry);
}
ProtocolUtils.writeCompoundTag(buf, registryContainer);
ProtocolUtils.writeString(buf, dimensionInfo.getRegistryIdentifier()); ProtocolUtils.writeString(buf, dimensionInfo.getRegistryIdentifier());
ProtocolUtils.writeString(buf, dimensionInfo.getLevelName()); ProtocolUtils.writeString(buf, dimensionInfo.getLevelName());
} else if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) { } else if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) {