3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00

Fixes to hover event handling, some cleanup

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-04-22 16:05:44 +02:00
Ursprung 5069b26c2f
Commit d3d6d4f1cd
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
2 geänderte Dateien mit 20 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -468,7 +468,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final ListTag<CompoundTag> attributeModifiersTag = tag.getListTag("AttributeModifiers", CompoundTag.class);
if (attributeModifiersTag != null) {
updateAttributes(data, tag, attributeModifiersTag, (hideFlagsValue & StructuredDataConverter.HIDE_ATTRIBUTES) == 0);
updateAttributes(data, attributeModifiersTag, (hideFlagsValue & StructuredDataConverter.HIDE_ATTRIBUTES) == 0);
}
final CompoundTag fireworksTag = tag.getCompoundTag("Fireworks");
@ -653,6 +653,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
if (possibleEffectsTag == null) {
return;
}
final List<FoodEffect> possibleEffects = new ArrayList<>();
for (final CompoundTag effect : possibleEffectsTag) {
final CompoundTag potionEffectTag = effect.getCompoundTag("effect");
@ -675,6 +676,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
if (rulesTag == null) {
return;
}
final List<ToolRule> rules = new ArrayList<>();
for (final CompoundTag tag : rulesTag) {
HolderSet blocks = null;
@ -709,6 +711,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
if (patternTag == null) {
continue;
}
final String assetId = patternTag.getString("asset_id");
final String translationKey = patternTag.getString("translation_key");
final int dyeColor = tag.getInt("dye_color");
@ -784,7 +787,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
);
}
private void updateAttributes(final StructuredDataContainer data, final CompoundTag tag, final ListTag<CompoundTag> attributeModifiersTag, final boolean showInTooltip) {
private void updateAttributes(final StructuredDataContainer data, final ListTag<CompoundTag> attributeModifiersTag, final boolean showInTooltip) {
final List<AttributeModifier> modifiers = new ArrayList<>();
for (int i = 0; i < attributeModifiersTag.size(); i++) {
final CompoundTag modifierTag = attributeModifiersTag.get(i);

Datei anzeigen

@ -196,10 +196,10 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
return;
}
CompoundTag tagTag;
final CompoundTag tagTag;
try {
tagTag = (CompoundTag) SerializerVersion.V1_20_3.toTag(tag.getValue());
} catch (Exception e) {
} catch (final Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Error reading 1.20.3 NBT in show_item: " + contentsTag, e);
}
@ -217,17 +217,22 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
return;
}
final String itemName = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().identifier(newItem.identifier());
if (itemName != null) {
contentsTag.putString("id", itemName);
if (newItem.identifier() != 0) {
final String itemName = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().mappedIdentifier(newItem.identifier());
if (itemName != null) {
contentsTag.putString("id", itemName);
}
} else {
// Cannot be air
contentsTag.putString("id", "minecraft:stone");
}
final Map<StructuredDataKey<?>, StructuredData<?>> data = newItem.structuredData().data();
if (!data.isEmpty()) {
CompoundTag components;
final CompoundTag components;
try {
components = toTag(data, false);
} catch (Exception e) {
} catch (final Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Error writing 1.20.5 components in show_item!", e);
}
@ -783,7 +788,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
final ListTag<CompoundTag> tag = new ListTag<>(CompoundTag.class);
final ListTag<CompoundTag> items = convertItemArray(value);
for (int i = 0; i < items.size(); i++) {
final CompoundTag itemTag = items.get(i);
final CompoundTag itemTag = new CompoundTag();
itemTag.putInt("slot", i);
itemTag.put("item", items.get(i));
tag.add(itemTag);
@ -942,11 +947,11 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
// ---------------------------------------------------------------------------------------
protected IntTag convertPositiveInt(final Integer value) {
return convertIntRange(1, Integer.MAX_VALUE, value);
return convertIntRange(value, 1, Integer.MAX_VALUE);
}
protected IntTag convertNonNegativeInt(final Integer value) {
return convertIntRange(0, Integer.MAX_VALUE, value);
return convertIntRange(value, 0, Integer.MAX_VALUE);
}
protected IntTag convertIntRange(final Integer value, final int min, final int max) {