Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Be even more defensive about half valid items in hover events
While they aren't particularly useful or intended, they were valid
Dieser Commit ist enthalten in:
Ursprung
1f43ff571d
Commit
798b70cbe6
@ -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 {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren