Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 08:10:10 +01:00
Emulate "trim_pattern" registry in 1.19.4 -> 1.20 if not present (#557)
Dieser Commit ist enthalten in:
Ursprung
817080b7a6
Commit
4627142700
@ -18,9 +18,9 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_19_4to1_20;
|
package com.viaversion.viabackwards.protocol.protocol1_19_4to1_20;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
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.SoundRewriter;
|
||||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
|
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.data.BackwardsMappings;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets.BlockItemPackets1_20;
|
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets.BlockItemPackets1_20;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets.EntityPackets1_20;
|
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets.EntityPackets1_20;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
@ -29,14 +29,13 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
|
|
||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public final class Protocol1_19_4To1_20 extends BackwardsProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_4, ServerboundPackets1_19_4, ServerboundPackets1_19_4> {
|
public final class Protocol1_19_4To1_20 extends BackwardsProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_4, ServerboundPackets1_19_4, ServerboundPackets1_19_4> {
|
||||||
|
|
||||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.20", "1.19.4", Protocol1_20To1_19_4.class);
|
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||||
private final TranslatableRewriter<ClientboundPackets1_19_4> translatableRewriter = new TranslatableRewriter<>(this);
|
private final TranslatableRewriter<ClientboundPackets1_19_4> translatableRewriter = new TranslatableRewriter<>(this);
|
||||||
private final EntityPackets1_20 entityRewriter = new EntityPackets1_20(this);
|
private final EntityPackets1_20 entityRewriter = new EntityPackets1_20(this);
|
||||||
private final BlockItemPackets1_20 itemRewriter = new BlockItemPackets1_20(this);
|
private final BlockItemPackets1_20 itemRewriter = new BlockItemPackets1_20(this);
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||||
|
* Copyright (C) 2023 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_4to1_20.data;
|
||||||
|
|
||||||
|
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings {
|
||||||
|
|
||||||
|
private CompoundTag trimPatternRegistry;
|
||||||
|
|
||||||
|
public BackwardsMappings() {
|
||||||
|
super("1.20", "1.19.4", Protocol1_20To1_19_4.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadExtras(CompoundTag data) {
|
||||||
|
super.loadExtras(data);
|
||||||
|
|
||||||
|
try {
|
||||||
|
trimPatternRegistry = BinaryTagIO.readInputStream(VBMappingDataLoader.getResource("trim_pattern-1.19.4.nbt"));
|
||||||
|
} catch (final IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getTrimPatternRegistry() {
|
||||||
|
return trimPatternRegistry;
|
||||||
|
}
|
||||||
|
}
|
@ -165,7 +165,17 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
|
|||||||
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking
|
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final CompoundTag registry = wrapper.get(Type.NBT, 0);
|
final CompoundTag registry = wrapper.get(Type.NBT, 0);
|
||||||
final ListTag values = ((CompoundTag) registry.get("minecraft:trim_pattern")).get("value");
|
|
||||||
|
ListTag values;
|
||||||
|
// A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing
|
||||||
|
// on a 1.19.4 client there is an exception, so in case the 1.20 server doesn't send the element we put in an original 1.20 element
|
||||||
|
if (registry.contains("minecraft:trim_pattern")) {
|
||||||
|
values = ((CompoundTag) registry.get("minecraft:trim_pattern")).get("value");
|
||||||
|
} else {
|
||||||
|
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().clone();
|
||||||
|
registry.put("minecraft:trim_pattern", trimPatternRegistry);
|
||||||
|
values = trimPatternRegistry.get("value");
|
||||||
|
}
|
||||||
for (final Tag entry : values) {
|
for (final Tag entry : values) {
|
||||||
final CompoundTag element = ((CompoundTag) entry).get("element");
|
final CompoundTag element = ((CompoundTag) entry).get("element");
|
||||||
final StringTag templateItem = element.get("template_item");
|
final StringTag templateItem = element.get("template_item");
|
||||||
|
Binäre Datei nicht angezeigt.
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren