mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-23 10:35:12 +01:00
Fix custom enchantments
This commit is contained in:
parent
a2f5120069
commit
32161333dd
@ -315,11 +315,12 @@ public class InventoryPackets {
|
||||
for (Tag enchEntry : ench) {
|
||||
if (enchEntry instanceof CompoundTag) {
|
||||
CompoundTag enchantmentEntry = new CompoundTag("");
|
||||
enchantmentEntry.put(new StringTag("id",
|
||||
MappingData.oldEnchantmentsIds.get(
|
||||
(short) ((CompoundTag) enchEntry).get("id").getValue()
|
||||
)
|
||||
));
|
||||
short oldId = (short) ((CompoundTag) enchEntry).get("id").getValue();
|
||||
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
||||
if (newId == null){
|
||||
newId = "viaversion:legacy/"+oldId;
|
||||
}
|
||||
enchantmentEntry.put(new StringTag("id", newId));
|
||||
enchantmentEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchEntry).get("lvl").getValue()));
|
||||
enchantments.add(enchantmentEntry);
|
||||
}
|
||||
@ -333,10 +334,13 @@ public class InventoryPackets {
|
||||
for (Tag enchEntry : storedEnch) {
|
||||
if (enchEntry instanceof CompoundTag) {
|
||||
CompoundTag enchantmentEntry = new CompoundTag("");
|
||||
short oldId = (short) ((CompoundTag) enchEntry).get("id").getValue();
|
||||
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
||||
if (newId == null) {
|
||||
newId = "viaversion:legacy/"+oldId;
|
||||
}
|
||||
enchantmentEntry.put(new StringTag("id",
|
||||
MappingData.oldEnchantmentsIds.get(
|
||||
(short) ((CompoundTag) enchEntry).get("id").getValue()
|
||||
)
|
||||
newId
|
||||
));
|
||||
enchantmentEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchEntry).get("lvl").getValue()));
|
||||
newStoredEnch.add(enchantmentEntry);
|
||||
@ -495,12 +499,15 @@ public class InventoryPackets {
|
||||
for (Tag enchantmentEntry : enchantments) {
|
||||
if (enchantmentEntry instanceof CompoundTag) {
|
||||
CompoundTag enchEntry = new CompoundTag("");
|
||||
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
||||
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
|
||||
if (oldId == null && newId.startsWith("viaversion:legacy/")){
|
||||
oldId = Short.valueOf(newId.substring(18));
|
||||
}
|
||||
enchEntry.put(
|
||||
new ShortTag(
|
||||
"id",
|
||||
MappingData.oldEnchantmentsIds.inverse().get(
|
||||
(String) ((CompoundTag) enchantmentEntry).get("id").getValue()
|
||||
)
|
||||
oldId
|
||||
)
|
||||
);
|
||||
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
||||
|
Loading…
Reference in New Issue
Block a user