3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Don't load mappings in 1.19.4 protocol

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-02-03 10:48:46 +01:00
Ursprung 64b3771899
Commit 93654b8eaf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 33 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -18,21 +18,19 @@
package com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.data.MappingDataBase;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.data.EntityPackets;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.packets.EntityPackets;
import com.viaversion.viaversion.rewriter.CommandRewriter;
public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPackets1_19_3, ClientboundPackets1_19_4, ServerboundPackets1_19_3, ServerboundPackets1_19_4> {
private static final MappingData MAPPINGS = new MappingDataBase("1.19.3", "1.19.3");
private final EntityPackets entityRewriter = new EntityPackets(this);
public Protocol1_19_4To1_19_3() {
@ -53,6 +51,16 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
super.handleArgument(wrapper, argumentType);
}
}
@Override
protected String argumentType(final int argumentTypeId) {
return Protocol1_19_3To1_19_1.MAPPINGS.getArgumentTypeMappings().mappedIdentifier(argumentTypeId);
}
@Override
protected int mappedArgumentTypeId(final String mappedArgumentType) {
return Protocol1_19_3To1_19_1.MAPPINGS.getArgumentTypeMappings().mappedId(mappedArgumentType);
}
};
commandRewriter.registerDeclareCommands1_19(ClientboundPackets1_19_3.DECLARE_COMMANDS);
}
@ -61,9 +69,4 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_3Types.PLAYER));
}
@Override
public MappingData getMappingData() {
return MAPPINGS;
}
}

Datei anzeigen

@ -15,7 +15,7 @@
* 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.viaversion.protocols.protocol1_19_4to1_19_3.data;
package com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.packets;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;

Datei anzeigen

@ -23,8 +23,6 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
import java.util.Map;
@ -82,13 +80,6 @@ public class CommandRewriter {
});
}
public void handleArgument(PacketWrapper wrapper, String argumentType) throws Exception {
CommandArgumentConsumer handler = parserHandlers.get(argumentType);
if (handler != null) {
handler.accept(wrapper);
}
}
public void registerDeclareCommands(ClientboundPacketType packetType) {
protocol.registerClientbound(packetType, new PacketRemapper() {
@Override
@ -149,10 +140,10 @@ public class CommandRewriter {
if (nodeType == 2) { // Argument node
int argumentTypeId = wrapper.read(Type.VAR_INT);
String argumentType = protocol.getMappingData().getArgumentTypeMappings().identifier(argumentTypeId);
String argumentType = argumentType(argumentTypeId);
String newArgumentType = handleArgumentType(argumentType);
Preconditions.checkArgument(newArgumentType != null, "No mapping for argument type " + argumentType);
wrapper.write(Type.VAR_INT, protocol.getMappingData().getArgumentTypeMappings().mappedId(newArgumentType));
Preconditions.checkNotNull(newArgumentType, "No mapping for argument type %s", argumentType);
wrapper.write(Type.VAR_INT, mappedArgumentTypeId(newArgumentType));
// Always call the handler using the previous name
handleArgument(wrapper, argumentType);
@ -169,19 +160,34 @@ public class CommandRewriter {
});
}
public void handleArgument(PacketWrapper wrapper, String argumentType) throws Exception {
CommandArgumentConsumer handler = parserHandlers.get(argumentType);
if (handler != null) {
handler.accept(wrapper);
}
}
/**
* Can be overridden if needed.
*
* @param argumentType argument type
* @return new argument type, or null if it should be removed
* @return mapped argument type
*/
public @Nullable String handleArgumentType(String argumentType) {
public String handleArgumentType(String argumentType) {
if (protocol.getMappingData() != null && protocol.getMappingData().getArgumentTypeMappings() != null) {
return protocol.getMappingData().getArgumentTypeMappings().mappedIdentifier(argumentType);
}
return argumentType;
}
protected String argumentType(int argumentTypeId) {
return protocol.getMappingData().getArgumentTypeMappings().identifier(argumentTypeId);
}
protected int mappedArgumentTypeId(String mappedArgumentType) {
return protocol.getMappingData().getArgumentTypeMappings().mappedId(mappedArgumentType);
}
@FunctionalInterface
public interface CommandArgumentConsumer {