Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-17 13:30:14 +01:00
1.19.3-rc1
Dieser Commit ist enthalten in:
Ursprung
d18825e700
Commit
383281cb9f
@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.5.0-1.19.3-pre3-SNAPSHOT"
|
||||
version = "4.5.0-1.19.3-rc1-SNAPSHOT"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
/**
|
||||
* To be overridden.
|
||||
*/
|
||||
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
protected void loadVBExtras(JsonObject unmapped, JsonObject mapped) {
|
||||
}
|
||||
|
||||
protected boolean shouldWarnOnMissing(String key) {
|
||||
|
@ -55,7 +55,10 @@ public class SoundRewriter extends com.viaversion.viaversion.rewriter.SoundRewri
|
||||
return wrapper -> {
|
||||
String soundId = wrapper.get(Type.STRING, 0);
|
||||
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) return;
|
||||
if (mappedId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.set(Type.STRING, 0, mappedId);
|
||||
} else {
|
||||
@ -89,4 +92,34 @@ public class SoundRewriter extends com.viaversion.viaversion.rewriter.SoundRewri
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler get1_19_3SoundHandler() {
|
||||
return wrapper -> {
|
||||
final int soundId = wrapper.read(Type.VAR_INT);
|
||||
if (soundId != 0) {
|
||||
final int mappedId = idRewriter.rewrite(soundId - 1); // Normalize the id
|
||||
if (mappedId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, mappedId + 1);
|
||||
}
|
||||
|
||||
// Is followed by the resource loation
|
||||
wrapper.write(Type.VAR_INT, 0);
|
||||
|
||||
String soundIdentifier = wrapper.read(Type.STRING);
|
||||
final String mappedIdentifier = protocol.getMappingData().getMappedNamedSound(soundIdentifier);
|
||||
if (mappedIdentifier != null) {
|
||||
if (mappedIdentifier.isEmpty()) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
soundIdentifier = mappedIdentifier;
|
||||
}
|
||||
wrapper.write(Type.STRING, soundIdentifier);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
public void loadVBExtras(JsonObject unmapped, JsonObject mapped) {
|
||||
enchantmentMappings = VBMappings.vbBuilder().warnOnMissing(false)
|
||||
.unmapped(oldMappings.getAsJsonArray("enchantments")).mapped(newMappings.getAsJsonObject("legacy_enchantments")).build();
|
||||
.unmapped(unmapped.getAsJsonArray("enchantments")).mapped(mapped.getAsJsonObject("legacy_enchantments")).build();
|
||||
for (Map.Entry<String, Integer> entry : StatisticMappings.CUSTOM_STATS.entrySet()) {
|
||||
statisticMappings.put(entry.getValue().intValue(), entry.getKey());
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
protected void loadVBExtras(JsonObject unmapped, JsonObject mapped) {
|
||||
for (Map.Entry<String, String> entry : Protocol1_16To1_15_2.MAPPINGS.getAttributeMappings().entrySet()) {
|
||||
attributeMappings.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadVBExtras(final JsonObject oldMappings, final JsonObject newMappings) {
|
||||
protected void loadVBExtras(final JsonObject unmapped, final JsonObject mapped) {
|
||||
for (final Object2IntMap.Entry<String> entry : Protocol1_18To1_17_1.MAPPINGS.blockEntityIds().object2IntEntrySet()) {
|
||||
blockEntities.put(entry.getIntValue(), entry.getKey());
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadVBExtras(final JsonObject oldMappings, final JsonObject newMappings) {
|
||||
protected void loadVBExtras(final JsonObject unmapped, final JsonObject mapped) {
|
||||
int i = 0;
|
||||
final JsonArray types = oldMappings.getAsJsonArray("argumenttypes");
|
||||
final JsonArray types = unmapped.getAsJsonArray("argumenttypes");
|
||||
this.argumentTypes = new String[types.size()];
|
||||
for (final JsonElement element : types) {
|
||||
final String id = element.getAsString();
|
||||
|
@ -19,9 +19,9 @@ package com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.packets.BlockItemPackets1_19_3;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.packets.EntityPackets1_19_3;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.storage.ChatSessionStorage;
|
||||
@ -59,7 +59,7 @@ import java.util.BitSet;
|
||||
|
||||
public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundPackets1_19_3, ClientboundPackets1_19_1, ServerboundPackets1_19_3, ServerboundPackets1_19_1> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.19.3", "1.19", Protocol1_19_3To1_19_1.class, true);
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||
private static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES_TYPE = new ByteArrayType.OptionalByteArrayType(256);
|
||||
private static final ByteArrayType SIGNATURE_BYTES_TYPE = new ByteArrayType(256);
|
||||
private final EntityPackets1_19_3 entityRewriter = new EntityPackets1_19_3(this);
|
||||
@ -93,22 +93,74 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
|
||||
final SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_19_3.ENTITY_SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_19_3.SOUND);
|
||||
registerClientbound(ClientboundPackets1_19_3.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
final int soundId = wrapper.read(Type.VAR_INT);
|
||||
if (soundId == 0) {
|
||||
wrapper.passthrough(Type.STRING); // String identifier
|
||||
wrapper.read(Type.OPTIONAL_FLOAT); // Fixed range
|
||||
wrapper.setPacketType(ClientboundPackets1_19_1.NAMED_SOUND);
|
||||
final int soundId = wrapper.read(Type.VAR_INT) - 1; // Normalize the id
|
||||
if (soundId != -1) {
|
||||
final int mappedId = MAPPINGS.getSoundMappings().getNewId(soundId);
|
||||
if (mappedId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, mappedId + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Normalize the sound id
|
||||
wrapper.write(Type.VAR_INT, soundId - 1);
|
||||
String soundIdentifier = wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.OPTIONAL_FLOAT); // Fixed range
|
||||
final String mappedIdentifier = MAPPINGS.getMappedNamedSound(soundIdentifier);
|
||||
if (mappedIdentifier != null) {
|
||||
if (mappedIdentifier.isEmpty()) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
soundIdentifier = mappedIdentifier;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, soundIdentifier);
|
||||
wrapper.setPacketType(ClientboundPackets1_19_1.NAMED_SOUND);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_19_3.ENTITY_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
final int soundId = wrapper.read(Type.VAR_INT) - 1; // Normalize the id
|
||||
if (soundId != -1) {
|
||||
final int mappedId = MAPPINGS.getSoundMappings().getNewId(soundId);
|
||||
if (mappedId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, mappedId + 1);
|
||||
}
|
||||
|
||||
// Convert the resource location to the corresponding integer id
|
||||
String soundIdentifier = wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.OPTIONAL_FLOAT); // Fixed range
|
||||
final String mappedIdentifier = MAPPINGS.getMappedNamedSound(soundIdentifier);
|
||||
if (mappedIdentifier != null) {
|
||||
if (mappedIdentifier.isEmpty()) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
soundIdentifier = mappedIdentifier;
|
||||
}
|
||||
|
||||
final int mappedId = MAPPINGS.mappedSound(soundIdentifier);
|
||||
if (mappedId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, mappedId);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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_19_1to1_19_3.data;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
||||
|
||||
public final class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings {
|
||||
|
||||
private final Object2IntMap<String> mappedSounds = new Object2IntOpenHashMap<>();
|
||||
|
||||
public BackwardsMappings() {
|
||||
super("1.19.3", "1.19", Protocol1_19_3To1_19_1.class, true);
|
||||
mappedSounds.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadVBExtras(final JsonObject unmapped, final JsonObject mapped) {
|
||||
int i = 0;
|
||||
for (final JsonElement sound : mapped.getAsJsonArray("sounds")) {
|
||||
mappedSounds.put(sound.getAsString(), i++);
|
||||
}
|
||||
}
|
||||
|
||||
public int mappedSound(final String sound) {
|
||||
return mappedSounds.getInt(sound.replace("minecraft:", ""));
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren