Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Fix enchantment glint behaviour in 1.10->1.11 (#4156)
Dieser Commit ist enthalten in:
Ursprung
a0a2794291
Commit
5287d4fb4f
@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.v1_10to1_11.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.ByteTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
@ -55,6 +56,22 @@ public class ItemPacketRewriter1_11 extends ItemRewriter<ClientboundPackets1_9_3
|
||||
item.setAmount(1);
|
||||
}
|
||||
EntityMappings1_11.toClientItem(item);
|
||||
|
||||
if (item == null || item.tag() == null) {
|
||||
return item;
|
||||
}
|
||||
CompoundTag tag = item.tag();
|
||||
|
||||
// 1.10 will display item glint if the list tag is present, 1.11+ only if at least one element is present
|
||||
ListTag enchTag = tag.getListTag("ench");
|
||||
if (enchTag != null && enchTag.isEmpty()) {
|
||||
tag.putBoolean(nbtTagName("clearEnch"), true);
|
||||
|
||||
CompoundTag dummyTag = new CompoundTag();
|
||||
dummyTag.putShort("id", Short.MAX_VALUE);
|
||||
|
||||
enchTag.add(dummyTag);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -63,12 +80,18 @@ public class ItemPacketRewriter1_11 extends ItemRewriter<ClientboundPackets1_9_3
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
if (item.tag() != null && item.tag().contains(nbtTagName())) {
|
||||
item.setAmount(item.tag().<ByteTag>removeUnchecked(nbtTagName()).asByte());
|
||||
if (item.tag().isEmpty()) {
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag != null) {
|
||||
if (tag.contains(nbtTagName())) {
|
||||
item.setAmount(tag.<ByteTag>removeUnchecked(nbtTagName()).asByte());
|
||||
if (tag.isEmpty()) {
|
||||
item.setTag(null);
|
||||
}
|
||||
}
|
||||
if (tag.remove(nbtTagName("clearEnch")) != null) {
|
||||
tag.put("ench", new ListTag());
|
||||
}
|
||||
}
|
||||
EntityMappings1_11.toServerItem(item);
|
||||
boolean newItem = item.identifier() >= 218 && item.identifier() <= 234;
|
||||
newItem |= item.identifier() == 449 || item.identifier() == 450;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren