3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-27 00:22:53 +01:00

Merge branch 'master' into dev

# Conflicts:
#	common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-01-31 22:58:51 +01:00
Commit 680d0642c9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
3 geänderte Dateien mit 4 neuen und 44 gelöschten Zeilen

Datei anzeigen

@ -308,8 +308,8 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
}
}
// Handle hover event changes in book pages
if ((item.identifier() == 758 || item.identifier() == 759) && tag != null) {
// Handle hover event changes in written book pages
if (item.identifier() == 759 && tag != null) {
Tag pagesTag = tag.get("pages");
if (pagesTag instanceof ListTag) {
for (Tag page : ((ListTag) pagesTag)) {

Datei anzeigen

@ -33,6 +33,8 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
@Override
protected void loadExtras(final CompoundTag data) {
super.loadExtras(data);
for (final Object2IntMap.Entry<String> entry : Protocol1_18To1_17_1.MAPPINGS.blockEntityIds().object2IntEntrySet()) {
blockEntities.put(entry.getIntValue(), entry.getKey());
}

Datei anzeigen

@ -20,27 +20,18 @@ package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPacket1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPacket1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.util.ComponentUtil;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<ClientboundPacket1_20_3, ServerboundPacket1_20_2, Protocol1_20_2To1_20_3> {
@ -166,37 +157,4 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<Clientboun
wrapper.read(Type.OPTIONAL_FLOAT); // Sound range
});
}
@Override
public @Nullable Item handleItemToClient(@Nullable final Item item) {
if (item == null) return null;
final CompoundTag tag = item.tag();
if (tag != null) {
updatePages(tag, "pages");
updatePages(tag, "filtered_pages");
}
return super.handleItemToClient(item);
}
private void updatePages(final CompoundTag tag, final String key) {
if (!(tag.get(key) instanceof ListTag)) {
return;
}
final ListTag pages = tag.get(key);
for (final Tag pageTag : pages) {
if (!(pageTag instanceof StringTag)) {
continue;
}
final StringTag stringTag = (StringTag) pageTag;
try {
final JsonElement updatedComponent = ComponentUtil.convertJson(stringTag.getValue(), ComponentUtil.SerializerVersion.V1_20_3, ComponentUtil.SerializerVersion.V1_19_4);
stringTag.setValue(updatedComponent.toString());
} catch (final Exception e) {
Via.getManager().debugHandler().error("Error converting book", e);
}
}
}
}