From 3b9b3ab2574e7db51f017b466ba0079c4bba8e43 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 21 Apr 2024 20:47:53 +0200 Subject: [PATCH] Use getFullItemMappings --- .../Protocol1_20_3To1_20_5.java | 5 +- .../data/BackwardsMappings.java | 50 - .../BlockItemPacketRewriter1_20_5.java | 5 +- .../rewriter/EntityPacketRewriter1_20_5.java | 2 +- .../viabackwards/data/sounds-1.20.3.json | 1543 ----------------- 5 files changed, 6 insertions(+), 1599 deletions(-) delete mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/data/BackwardsMappings.java delete mode 100644 common/src/main/resources/assets/viabackwards/data/sounds-1.20.3.json diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java index a28e9870..60342560 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java @@ -18,9 +18,9 @@ package com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5; 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_20_3to1_20_5.data.BackwardsMappings; import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.provider.TransferProvider; import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.rewriter.BlockItemPacketRewriter1_20_5; import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.rewriter.EntityPacketRewriter1_20_5; @@ -48,6 +48,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ServerboundPacket1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ServerboundPackets1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPacket1_20_5; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5; @@ -62,7 +63,7 @@ import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap; public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol { - public static final BackwardsMappings MAPPINGS = new BackwardsMappings(); + public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.20.5", "1.20.3", Protocol1_20_5To1_20_3.class); private static final ByteArrayType COOKIE_DATA_TYPE = new ByteArrayType(5120); private final EntityPacketRewriter1_20_5 entityRewriter = new EntityPacketRewriter1_20_5(this); private final BlockItemPacketRewriter1_20_5 itemRewriter = new BlockItemPacketRewriter1_20_5(this); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/data/BackwardsMappings.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/data/BackwardsMappings.java deleted file mode 100644 index 84d3c36d..00000000 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/data/BackwardsMappings.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards - * Copyright (C) 2016-2024 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 . - */ -package com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.data; - -import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader; -import com.viaversion.viaversion.libs.gson.JsonArray; -import com.viaversion.viaversion.libs.gson.JsonElement; -import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; -import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; -import org.checkerframework.checker.nullness.qual.Nullable; - -public final class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings { - - private String[] sounds; - - public BackwardsMappings() { - super("1.20.5", "1.20.3", Protocol1_20_5To1_20_3.class); - } - - @Override - protected void loadExtras(final CompoundTag data) { - super.loadExtras(data); - - final JsonArray sounds = BackwardsMappingDataLoader.INSTANCE.loadData("sounds-1.20.3.json").getAsJsonArray("sounds"); - this.sounds = new String[sounds.size()]; - int i = 0; - for (final JsonElement sound : sounds) { - this.sounds[i++] = sound.getAsString(); - } - } - - public @Nullable String mappedSoundName(final int mappedId) { - return mappedId >= 0 && mappedId < sounds.length ? sounds[mappedId] : null; - } -} diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java index f9a090eb..f0e89f76 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java @@ -32,7 +32,6 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.Recip import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPacket1_20_5; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5; -import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.rewriter.StructuredDataConverter; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.util.Key; @@ -96,7 +95,7 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem } } else if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("dust_color_transition")) { // fromColor, toColor, scale -> fromColor, scale, toColor - particle.add(3, Type.FLOAT, particle. removeArgument(6).getValue()); + particle.add(3, Type.FLOAT, particle.removeArgument(6).getValue()); } wrapper.set(Type.VAR_INT, 0, particle.id()); @@ -131,7 +130,7 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem } soundId = protocol.getMappingData().getSoundMappings().getNewId(soundId); - final String soundKey = protocol.getMappingData().mappedSoundName(soundId); + final String soundKey = Protocol1_20_5To1_20_3.MAPPINGS.soundName(soundId); wrapper.write(Type.STRING, soundKey != null ? soundKey : "minecraft:entity.generic.explode"); wrapper.write(Type.OPTIONAL_FLOAT, null); // Fixed range }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java index 97bae05c..416a9eb6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java @@ -151,7 +151,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter