22w19a (almost, also more dread)

This commit is contained in:
Nassim Jahnke 2022-05-12 22:15:53 +02:00
parent 5bffa2c51c
commit 1e0c0ebb2d
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
7 changed files with 211 additions and 8 deletions

View File

@ -5,7 +5,7 @@ plugins {
allprojects {
group = "com.viaversion"
version = "4.3.0-22w18a-SNAPSHOT"
version = "4.3.0-22w19a-SNAPSHOT"
description = "Allow older clients to join newer server versions."
}

View File

@ -23,8 +23,10 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.data.BackwardsMappings;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.data.CommandRewriter1_19;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.packets.BlockItemPackets1_19;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.packets.EntityPackets1_19;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage.DimensionRegistryStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
@ -141,7 +143,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
new StatisticsRewriter(this).register(ClientboundPackets1_19.STATISTICS);
final CommandRewriter commandRewriter = new CommandRewriter(this);
final CommandRewriter commandRewriter = new CommandRewriter1_19(this);
registerClientbound(ClientboundPackets1_19.DECLARE_COMMANDS, new PacketRemapper() {
@Override
public void registerMap() {
@ -181,10 +183,13 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
}
});
cancelClientbound(ClientboundPackets1_19.SERVER_DATA);
cancelClientbound(ClientboundPackets1_19.CHAT_PREVIEW);
registerClientbound(ClientboundPackets1_19.PLAYER_CHAT, ClientboundPackets1_18.CHAT_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.COMPONENT); // Message
read(Type.OPTIONAL_COMPONENT); //TODO Oh god oh no
map(Type.VAR_INT, Type.BYTE); // Chat type
map(Type.UUID); // Sender
handler(wrapper -> {
@ -223,6 +228,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
wrapper.write(Type.VAR_INT, 0); // No signatures
} else {
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, EMPTY_BYTES); // Signature
wrapper.write(Type.BOOLEAN, false); // No signed preview
}
});
}
@ -266,6 +272,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
@Override
public void init(final UserConnection user) {
user.put(new DimensionRegistryStorage());
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19Types.PLAYER, true));
}
@ -293,7 +300,6 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
return TextReplacementConfig.builder().matchLiteral("%s").replacement(GsonComponentSerializer.gson().deserializeFromTree(replacement)).once().build();
}
//TODO keep updated, sanity checks for system messages
private void handleChatType(final PacketWrapper wrapper, final JsonElement senderName, final JsonElement teamName, final JsonElement text) throws Exception {
translatableRewriter.processText(text);

View File

@ -0,0 +1,39 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2022 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.data;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.rewriter.CommandRewriter;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class CommandRewriter1_19 extends CommandRewriter {
public CommandRewriter1_19(Protocol protocol) {
super(protocol);
//TODO
}
@Override
protected @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:resource") || argumentType.equals("minecraft:resource_or_tag")) {
return "brigadier:string";
}
return super.handleArgumentType(argumentType);
}
}

View File

@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.packets;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.Protocol1_18_2To1_19;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage.DimensionRegistryStorage;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage.StoredPainting;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
@ -40,6 +41,9 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import java.util.HashMap;
import java.util.Map;
public final class EntityPackets1_19 extends EntityRewriter<Protocol1_18_2To1_19> {
public EntityPackets1_19(final Protocol1_18_2To1_19 protocol) {
@ -117,7 +121,29 @@ public final class EntityPackets1_19 extends EntityRewriter<Protocol1_18_2To1_19
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // Worlds
map(Type.NBT); // Dimension registry
map(Type.NBT); // Current dimension data
handler(wrapper -> {
final String dimensionKey = wrapper.read(Type.STRING);
final ListTag dimensions = ((CompoundTag) wrapper.get(Type.NBT, 0).get("minecraft:dimension_type")).get("value");
final Map<String, CompoundTag> dimensionsMap = new HashMap<>(dimensions.size());
boolean found = false;
for (final Tag dimension : dimensions) {
final CompoundTag dimensionCompound = (CompoundTag) dimension;
final StringTag nameTag = dimensionCompound.get("name");
dimensionsMap.put(nameTag.getValue(), dimensionCompound);
if (!found && nameTag.getValue().equals(dimensionKey)) {
final CompoundTag compoundTag = dimensionCompound.get("element");
wrapper.write(Type.NBT, compoundTag);
found = true;
}
}
if (!found) {
throw new IllegalStateException("Could not find dimension " + dimensionKey + " in dimension registry");
}
wrapper.user().get(DimensionRegistryStorage.class).setDimensions(dimensionsMap);
});
map(Type.STRING); // World
map(Type.LONG); // Seed
map(Type.VAR_INT); // Max players
@ -145,7 +171,15 @@ public final class EntityPackets1_19 extends EntityRewriter<Protocol1_18_2To1_19
protocol.registerClientbound(ClientboundPackets1_19.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.NBT); // Dimension data
handler(wrapper -> {
final String dimensionKey = wrapper.read(Type.STRING);
final CompoundTag dimension = wrapper.user().get(DimensionRegistryStorage.class).dimension(dimensionKey);
if (dimension == null) {
throw new IllegalArgumentException("Could not find dimension " + dimensionKey + " in dimension registry");
}
wrapper.write(Type.NBT, dimension);
});
map(Type.STRING); // World
handler(worldDataTrackerHandler(0));
}
@ -179,7 +213,9 @@ public final class EntityPackets1_19 extends EntityRewriter<Protocol1_18_2To1_19
// Remove public profile signature
if (wrapper.read(Type.BOOLEAN)) {
wrapper.read(Type.NBT); // Signature
wrapper.read(Type.LONG); // Timestamp
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Key
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature
}
} else if (action == 1 || action == 2) { // Update gamemode/update latency
wrapper.passthrough(Type.VAR_INT);

View File

@ -0,0 +1,38 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2022 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
import java.util.Map;
public final class DimensionRegistryStorage implements StorableObject {
private Map<String, CompoundTag> dimensions = new HashMap<>();
public @Nullable CompoundTag dimension(final String dimensionKey) {
return dimensions.get(dimensionKey);
}
public void setDimensions(final Map<String, CompoundTag> dimensions) {
this.dimensions = dimensions;
}
}

View File

@ -292,7 +292,91 @@
"minecraft:flowering_azalea_leaves[distance=7,persistent=true,waterlogged=true]": "minecraft:flowering_azalea_leaves[distance=7,persistent=true]",
"minecraft:flowering_azalea_leaves[distance=7,persistent=true,waterlogged=false]": "minecraft:flowering_azalea_leaves[distance=7,persistent=true]",
"minecraft:flowering_azalea_leaves[distance=7,persistent=false,waterlogged=true]": "minecraft:flowering_azalea_leaves[distance=7,persistent=false]",
"minecraft:flowering_azalea_leaves[distance=7,persistent=false,waterlogged=false]": "minecraft:flowering_azalea_leaves[distance=7,persistent=false]"
"minecraft:flowering_azalea_leaves[distance=7,persistent=false,waterlogged=false]": "minecraft:flowering_azalea_leaves[distance=7,persistent=false]",
"minecraft:chest[type=single,facing=north,waterlogged=true]": "minecraft:chest[facing=north,type=single,waterlogged=true]",
"minecraft:chest[type=single,facing=north,waterlogged=false]": "minecraft:chest[facing=north,type=single,waterlogged=false]",
"minecraft:chest[type=left,facing=north,waterlogged=true]": "minecraft:chest[facing=north,type=left,waterlogged=true]",
"minecraft:chest[type=left,facing=north,waterlogged=false]": "minecraft:chest[facing=north,type=left,waterlogged=false]",
"minecraft:chest[type=right,facing=north,waterlogged=true]": "minecraft:chest[facing=north,type=right,waterlogged=true]",
"minecraft:chest[type=right,facing=north,waterlogged=false]": "minecraft:chest[facing=north,type=right,waterlogged=false]",
"minecraft:chest[type=single,facing=south,waterlogged=true]": "minecraft:chest[facing=south,type=single,waterlogged=true]",
"minecraft:chest[type=single,facing=south,waterlogged=false]": "minecraft:chest[facing=south,type=single,waterlogged=false]",
"minecraft:chest[type=left,facing=south,waterlogged=true]": "minecraft:chest[facing=south,type=left,waterlogged=true]",
"minecraft:chest[type=left,facing=south,waterlogged=false]": "minecraft:chest[facing=south,type=left,waterlogged=false]",
"minecraft:chest[type=right,facing=south,waterlogged=true]": "minecraft:chest[facing=south,type=right,waterlogged=true]",
"minecraft:chest[type=right,facing=south,waterlogged=false]": "minecraft:chest[facing=south,type=right,waterlogged=false]",
"minecraft:chest[type=single,facing=west,waterlogged=true]": "minecraft:chest[facing=west,type=single,waterlogged=true]",
"minecraft:chest[type=single,facing=west,waterlogged=false]": "minecraft:chest[facing=west,type=single,waterlogged=false]",
"minecraft:chest[type=left,facing=west,waterlogged=true]": "minecraft:chest[facing=west,type=left,waterlogged=true]",
"minecraft:chest[type=left,facing=west,waterlogged=false]": "minecraft:chest[facing=west,type=left,waterlogged=false]",
"minecraft:chest[type=right,facing=west,waterlogged=true]": "minecraft:chest[facing=west,type=right,waterlogged=true]",
"minecraft:chest[type=right,facing=west,waterlogged=false]": "minecraft:chest[facing=west,type=right,waterlogged=false]",
"minecraft:chest[type=single,facing=east,waterlogged=true]": "minecraft:chest[facing=east,type=single,waterlogged=true]",
"minecraft:chest[type=single,facing=east,waterlogged=false]": "minecraft:chest[facing=east,type=single,waterlogged=false]",
"minecraft:chest[type=left,facing=east,waterlogged=true]": "minecraft:chest[facing=east,type=left,waterlogged=true]",
"minecraft:chest[type=left,facing=east,waterlogged=false]": "minecraft:chest[facing=east,type=left,waterlogged=false]",
"minecraft:chest[type=right,facing=east,waterlogged=true]": "minecraft:chest[facing=east,type=right,waterlogged=true]",
"minecraft:chest[type=right,facing=east,waterlogged=false]": "minecraft:chest[facing=east,type=right,waterlogged=false]",
"minecraft:trapped_chest[type=single,facing=north,waterlogged=true]": "minecraft:trapped_chest[facing=north,type=single,waterlogged=true]",
"minecraft:trapped_chest[type=single,facing=north,waterlogged=false]": "minecraft:trapped_chest[facing=north,type=single,waterlogged=false]",
"minecraft:trapped_chest[type=left,facing=north,waterlogged=true]": "minecraft:trapped_chest[facing=north,type=left,waterlogged=true]",
"minecraft:trapped_chest[type=left,facing=north,waterlogged=false]": "minecraft:trapped_chest[facing=north,type=left,waterlogged=false]",
"minecraft:trapped_chest[type=right,facing=north,waterlogged=true]": "minecraft:trapped_chest[facing=north,type=right,waterlogged=true]",
"minecraft:trapped_chest[type=right,facing=north,waterlogged=false]": "minecraft:trapped_chest[facing=north,type=right,waterlogged=false]",
"minecraft:trapped_chest[type=single,facing=south,waterlogged=true]": "minecraft:trapped_chest[facing=south,type=single,waterlogged=true]",
"minecraft:trapped_chest[type=single,facing=south,waterlogged=false]": "minecraft:trapped_chest[facing=south,type=single,waterlogged=false]",
"minecraft:trapped_chest[type=left,facing=south,waterlogged=true]": "minecraft:trapped_chest[facing=south,type=left,waterlogged=true]",
"minecraft:trapped_chest[type=left,facing=south,waterlogged=false]": "minecraft:trapped_chest[facing=south,type=left,waterlogged=false]",
"minecraft:trapped_chest[type=right,facing=south,waterlogged=true]": "minecraft:trapped_chest[facing=south,type=right,waterlogged=true]",
"minecraft:trapped_chest[type=right,facing=south,waterlogged=false]": "minecraft:trapped_chest[facing=south,type=right,waterlogged=false]",
"minecraft:trapped_chest[type=single,facing=west,waterlogged=true]": "minecraft:trapped_chest[facing=west,type=single,waterlogged=true]",
"minecraft:trapped_chest[type=single,facing=west,waterlogged=false]": "minecraft:trapped_chest[facing=west,type=single,waterlogged=false]",
"minecraft:trapped_chest[type=left,facing=west,waterlogged=true]": "minecraft:trapped_chest[facing=west,type=left,waterlogged=true]",
"minecraft:trapped_chest[type=left,facing=west,waterlogged=false]": "minecraft:trapped_chest[facing=west,type=left,waterlogged=false]",
"minecraft:trapped_chest[type=right,facing=west,waterlogged=true]": "minecraft:trapped_chest[facing=west,type=right,waterlogged=true]",
"minecraft:trapped_chest[type=right,facing=west,waterlogged=false]": "minecraft:trapped_chest[facing=west,type=right,waterlogged=false]",
"minecraft:trapped_chest[type=single,facing=east,waterlogged=true]": "minecraft:trapped_chest[facing=east,type=single,waterlogged=true]",
"minecraft:trapped_chest[type=single,facing=east,waterlogged=false]": "minecraft:trapped_chest[facing=east,type=single,waterlogged=false]",
"minecraft:trapped_chest[type=left,facing=east,waterlogged=true]": "minecraft:trapped_chest[facing=east,type=left,waterlogged=true]",
"minecraft:trapped_chest[type=left,facing=east,waterlogged=false]": "minecraft:trapped_chest[facing=east,type=left,waterlogged=false]",
"minecraft:trapped_chest[type=right,facing=east,waterlogged=true]": "minecraft:trapped_chest[facing=east,type=right,waterlogged=true]",
"minecraft:trapped_chest[type=right,facing=east,waterlogged=false]": "minecraft:trapped_chest[facing=east,type=right,waterlogged=false]",
"minecraft:moving_piston[type=normal,facing=north]": "minecraft:moving_piston[facing=north,type=normal]",
"minecraft:moving_piston[type=sticky,facing=north]": "minecraft:moving_piston[facing=north,type=sticky]",
"minecraft:moving_piston[type=normal,facing=east]": "minecraft:moving_piston[facing=east,type=normal]",
"minecraft:moving_piston[type=sticky,facing=east]": "minecraft:moving_piston[facing=east,type=sticky]",
"minecraft:moving_piston[type=normal,facing=south]": "minecraft:moving_piston[facing=south,type=normal]",
"minecraft:moving_piston[type=sticky,facing=south]": "minecraft:moving_piston[facing=south,type=sticky]",
"minecraft:moving_piston[type=normal,facing=west]": "minecraft:moving_piston[facing=west,type=normal]",
"minecraft:moving_piston[type=sticky,facing=west]": "minecraft:moving_piston[facing=west,type=sticky]",
"minecraft:moving_piston[type=normal,facing=up]": "minecraft:moving_piston[facing=up,type=normal]",
"minecraft:moving_piston[type=sticky,facing=up]": "minecraft:moving_piston[facing=up,type=sticky]",
"minecraft:moving_piston[type=normal,facing=down]": "minecraft:moving_piston[facing=down,type=normal]",
"minecraft:moving_piston[type=sticky,facing=down]": "minecraft:moving_piston[facing=down,type=sticky]",
"minecraft:piston_head[type=normal,facing=north,short=true]": "minecraft:piston_head[facing=north,short=true,type=normal]",
"minecraft:piston_head[type=sticky,facing=north,short=true]": "minecraft:piston_head[facing=north,short=true,type=sticky]",
"minecraft:piston_head[type=normal,facing=north,short=false]": "minecraft:piston_head[facing=north,short=false,type=normal]",
"minecraft:piston_head[type=sticky,facing=north,short=false]": "minecraft:piston_head[facing=north,short=false,type=sticky]",
"minecraft:piston_head[type=normal,facing=east,short=true]": "minecraft:piston_head[facing=east,short=true,type=normal]",
"minecraft:piston_head[type=sticky,facing=east,short=true]": "minecraft:piston_head[facing=east,short=true,type=sticky]",
"minecraft:piston_head[type=normal,facing=east,short=false]": "minecraft:piston_head[facing=east,short=false,type=normal]",
"minecraft:piston_head[type=sticky,facing=east,short=false]": "minecraft:piston_head[facing=east,short=false,type=sticky]",
"minecraft:piston_head[type=normal,facing=south,short=true]": "minecraft:piston_head[facing=south,short=true,type=normal]",
"minecraft:piston_head[type=sticky,facing=south,short=true]": "minecraft:piston_head[facing=south,short=true,type=sticky]",
"minecraft:piston_head[type=normal,facing=south,short=false]": "minecraft:piston_head[facing=south,short=false,type=normal]",
"minecraft:piston_head[type=sticky,facing=south,short=false]": "minecraft:piston_head[facing=south,short=false,type=sticky]",
"minecraft:piston_head[type=normal,facing=west,short=true]": "minecraft:piston_head[facing=west,short=true,type=normal]",
"minecraft:piston_head[type=sticky,facing=west,short=true]": "minecraft:piston_head[facing=west,short=true,type=sticky]",
"minecraft:piston_head[type=normal,facing=west,short=false]": "minecraft:piston_head[facing=west,short=false,type=normal]",
"minecraft:piston_head[type=sticky,facing=west,short=false]": "minecraft:piston_head[facing=west,short=false,type=sticky]",
"minecraft:piston_head[type=normal,facing=up,short=true]": "minecraft:piston_head[facing=up,short=true,type=normal]",
"minecraft:piston_head[type=sticky,facing=up,short=true]": "minecraft:piston_head[facing=up,short=true,type=sticky]",
"minecraft:piston_head[type=normal,facing=up,short=false]": "minecraft:piston_head[facing=up,short=false,type=normal]",
"minecraft:piston_head[type=sticky,facing=up,short=false]": "minecraft:piston_head[facing=up,short=false,type=sticky]",
"minecraft:piston_head[type=normal,facing=down,short=true]": "minecraft:piston_head[facing=down,short=true,type=normal]",
"minecraft:piston_head[type=sticky,facing=down,short=true]": "minecraft:piston_head[facing=down,short=true,type=sticky]",
"minecraft:piston_head[type=normal,facing=down,short=false]": "minecraft:piston_head[facing=down,short=false,type=normal]",
"minecraft:piston_head[type=sticky,facing=down,short=false]": "minecraft:piston_head[facing=down,short=false,type=sticky]"
},
"sounds": {
"music.overworld.deep_dark": "",

View File

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions]
# ViaVersion
viaver = "4.3.0-22w18a-SNAPSHOT"
viaver = "4.3.0-22w19a-SNAPSHOT"
# Common provided
netty = "4.0.20.Final"