Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Merge pull request #94 from Gerrygames/1.13_items
add dummy enchantment for 1.13 enchatments
Dieser Commit ist enthalten in:
Commit
b1246b6ffc
@ -634,6 +634,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
|||||||
ListTag noMapped = new ListTag(NBT_TAG_NAME + "|Enchantments", CompoundTag.class);
|
ListTag noMapped = new ListTag(NBT_TAG_NAME + "|Enchantments", CompoundTag.class);
|
||||||
ListTag ench = new ListTag("ench", CompoundTag.class);
|
ListTag ench = new ListTag("ench", CompoundTag.class);
|
||||||
List<Tag> lore = new ArrayList<>();
|
List<Tag> lore = new ArrayList<>();
|
||||||
|
boolean dummyEnchatment = true;
|
||||||
for (Tag enchantmentEntry : enchantments.clone()) {
|
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||||
if (enchantmentEntry instanceof CompoundTag) {
|
if (enchantmentEntry instanceof CompoundTag) {
|
||||||
CompoundTag enchEntry = new CompoundTag("");
|
CompoundTag enchEntry = new CompoundTag("");
|
||||||
@ -642,6 +643,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
|||||||
lore.add(new StringTag("", enchantmentMappings.get(newId)));
|
lore.add(new StringTag("", enchantmentMappings.get(newId)));
|
||||||
noMapped.add(enchantmentEntry);
|
noMapped.add(enchantmentEntry);
|
||||||
} else {
|
} else {
|
||||||
|
dummyEnchatment = false;
|
||||||
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
|
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
|
||||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||||
oldId = Short.valueOf(newId.substring(18));
|
oldId = Short.valueOf(newId.substring(18));
|
||||||
@ -657,6 +659,24 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(dummyEnchatment && enchantments.size() > 0) {
|
||||||
|
ByteTag hideFlags = tag.get("HideFlags");
|
||||||
|
if(hideFlags == null){
|
||||||
|
hideFlags = new ByteTag("HideFlags");
|
||||||
|
tag.put(new ByteTag(NBT_TAG_NAME + "|noHideFlags"));
|
||||||
|
}
|
||||||
|
tag.put(new ByteTag(NBT_TAG_NAME + "|dummyEnchatment", hideFlags.getValue()));
|
||||||
|
|
||||||
|
CompoundTag enchEntry = new CompoundTag("");
|
||||||
|
enchEntry.put(new ShortTag("id", (short) 0));
|
||||||
|
enchEntry.put(new ShortTag("lvl", (short) 1));
|
||||||
|
|
||||||
|
byte value = hideFlags.getValue();
|
||||||
|
hideFlags.setValue(value |= 1);
|
||||||
|
tag.put(hideFlags);
|
||||||
|
|
||||||
|
ench.add(enchEntry);
|
||||||
|
}
|
||||||
tag.remove("Enchantment");
|
tag.remove("Enchantment");
|
||||||
tag.put(noMapped);
|
tag.put(noMapped);
|
||||||
tag.put(ench);
|
tag.put(ench);
|
||||||
@ -864,10 +884,28 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
|||||||
if (tag.get("ench") instanceof ListTag) {
|
if (tag.get("ench") instanceof ListTag) {
|
||||||
ListTag ench = tag.get("ench");
|
ListTag ench = tag.get("ench");
|
||||||
ListTag enchantments = new ListTag("Enchantments", CompoundTag.class);
|
ListTag enchantments = new ListTag("Enchantments", CompoundTag.class);
|
||||||
|
boolean dummyEnchatment = false;
|
||||||
|
if(tag.get(NBT_TAG_NAME + "|dummyEnchatment") instanceof ByteTag){
|
||||||
|
ByteTag dummy = tag.get(NBT_TAG_NAME + "|dummyEnchatment");
|
||||||
|
if(tag.get("HideFlags") instanceof ByteTag){
|
||||||
|
if(tag.get(NBT_TAG_NAME + "|noHideFlags") instanceof ByteTag){
|
||||||
|
tag.remove("HideFlags");
|
||||||
|
tag.remove(NBT_TAG_NAME + "|noHideFlags");
|
||||||
|
}else{
|
||||||
|
ByteTag hideFlags = tag.get("HideFlags");
|
||||||
|
hideFlags.setValue(dummy.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dummyEnchatment = true;
|
||||||
|
tag.remove(NBT_TAG_NAME + "|dummyEnchatment");
|
||||||
|
}
|
||||||
for (Tag enchEntry : ench) {
|
for (Tag enchEntry : ench) {
|
||||||
if (enchEntry instanceof CompoundTag) {
|
if (enchEntry instanceof CompoundTag) {
|
||||||
CompoundTag enchantmentEntry = new CompoundTag("");
|
CompoundTag enchantmentEntry = new CompoundTag("");
|
||||||
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
|
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
|
||||||
|
if(dummyEnchatment && oldId == 0){
|
||||||
|
continue; //Skip dummy enchatment
|
||||||
|
}
|
||||||
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
||||||
if (newId == null) {
|
if (newId == null) {
|
||||||
newId = "viaversion:legacy/" + oldId;
|
newId = "viaversion:legacy/" + oldId;
|
||||||
@ -883,6 +921,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
|||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
enchantments.add(iterator.next());
|
enchantments.add(iterator.next());
|
||||||
}
|
}
|
||||||
|
tag.remove(NBT_TAG_NAME + "|Enchantments");
|
||||||
}
|
}
|
||||||
tag.remove("ench");
|
tag.remove("ench");
|
||||||
tag.put(enchantments);
|
tag.put(enchantments);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren