Compare commits

...

2 Commits

Author SHA1 Message Date
Nassim Jahnke 798b70cbe6
Be even more defensive about half valid items in hover events
While they aren't particularly useful or intended, they were valid
2024-04-26 19:00:37 +02:00
Nassim Jahnke 1f43ff571d
Bump to 4.10.1-SNAPSHOT 2024-04-26 18:26:37 +02:00
2 changed files with 15 additions and 17 deletions

View File

@ -194,19 +194,16 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
return; return;
} }
final int itemId = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().id(idTag.getValue()); int itemId = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().id(idTag.getValue());
if (itemId == -1) { if (itemId == -1) {
return; // Default to stone (anything that is not air)
itemId = 1;
} }
final StringTag tag = contentsTag.remove("tag"); final StringTag tag = contentsTag.remove("tag");
if (tag == null) {
return;
}
final CompoundTag tagTag; final CompoundTag tagTag;
try { try {
tagTag = (CompoundTag) SerializerVersion.V1_20_3.toTag(tag.getValue()); tagTag = tag != null ? (CompoundTag) SerializerVersion.V1_20_3.toTag(tag.getValue()) : null;
} catch (final Exception e) { } catch (final Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Error reading 1.20.3 NBT in show_item: " + contentsTag, e); Via.getPlatform().getLogger().log(Level.WARNING, "Error reading 1.20.3 NBT in show_item: " + contentsTag, e);
@ -214,19 +211,20 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
return; return;
} }
final Item oldItem = new DataItem(); final Item dataItem = new DataItem();
oldItem.setIdentifier(itemId); dataItem.setIdentifier(itemId);
if (tagTag != null) { // We don't need to remap data if there is none if (tagTag != null) { // We don't need to remap data if there is none
oldItem.setTag(tagTag); dataItem.setTag(tagTag);
} }
final Item newItem = protocol.getItemRewriter().handleItemToClient(connection, oldItem); final Item structuredItem = protocol.getItemRewriter().handleItemToClient(connection, dataItem);
if (newItem == null) { if (structuredItem.amount() < 1) {
return; // Cannot be empty
structuredItem.setAmount(1);
} }
if (newItem.identifier() != 0) { if (structuredItem.identifier() != 0) {
final String itemName = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().mappedIdentifier(newItem.identifier()); final String itemName = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().mappedIdentifier(structuredItem.identifier());
if (itemName != null) { if (itemName != null) {
contentsTag.putString("id", itemName); contentsTag.putString("id", itemName);
} }
@ -235,7 +233,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
contentsTag.putString("id", "minecraft:stone"); contentsTag.putString("id", "minecraft:stone");
} }
final Map<StructuredDataKey<?>, StructuredData<?>> data = newItem.structuredData().data(); final Map<StructuredDataKey<?>, StructuredData<?>> data = structuredItem.structuredData().data();
if (!data.isEmpty()) { if (!data.isEmpty()) {
final CompoundTag components; final CompoundTag components;
try { try {

View File

@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts # Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.10.0 projectVersion=4.10.1-SNAPSHOT
# Smile emoji # Smile emoji
mcVersions=1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9 mcVersions=1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9