Don't throw an exception on hover parse failure

This commit is contained in:
KennyTV 2021-04-11 13:35:53 +02:00
parent 4473f863c6
commit 0ee80dc41f
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
3 changed files with 9 additions and 5 deletions

View File

@ -129,7 +129,7 @@ public class TagRewriter {
};
}
public void handle(PacketWrapper wrapper, @Nullable IdRewriteFunction rewriteFunction, List<TagData> newTags) throws Exception {
public void handle(PacketWrapper wrapper, @Nullable IdRewriteFunction rewriteFunction, @Nullable List<TagData> newTags) throws Exception {
int tagsSize = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, newTags != null ? tagsSize + newTags.size() : tagsSize); // add new tags count

View File

@ -58,8 +58,11 @@ public class ComponentRewriter1_13 extends ComponentRewriter {
try {
tag = BinaryTagIO.readString(text);
} catch (Exception e) {
Via.getPlatform().getLogger().warning("Error reading NBT in show_item:" + text);
throw new RuntimeException(e);
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Error reading NBT in show_item:" + text);
e.printStackTrace();
}
return;
}
CompoundTag itemTag = tag.get("tag");

View File

@ -24,6 +24,7 @@ import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.RegistryType;
import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
@ -50,7 +51,7 @@ public class Protocol1_17To1_16_4 extends Protocol<ClientboundPackets1_16_2, Cli
@Override
protected void registerPackets() {
new MetadataRewriter1_17To1_16_4(this);
MetadataRewriter metadataRewriter = new MetadataRewriter1_17To1_16_4(this);
EntityPackets.register(this);
InventoryPackets.register(this);
@ -87,7 +88,7 @@ public class Protocol1_17To1_16_4 extends Protocol<ClientboundPackets1_16_2, Cli
}
});
new StatisticsRewriter(this, null).register(ClientboundPackets1_16_2.STATISTICS);
new StatisticsRewriter(this, metadataRewriter::getNewEntityId).register(ClientboundPackets1_16_2.STATISTICS);
SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);