mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-02-19 21:21:26 +01:00
Merge pull request #896 from creeper123123321/master
Support custom enchantments
This commit is contained in:
commit
ca415cc719
@ -315,12 +315,13 @@ public class InventoryPackets {
|
|||||||
for (Tag enchEntry : ench) {
|
for (Tag enchEntry : ench) {
|
||||||
if (enchEntry instanceof CompoundTag) {
|
if (enchEntry instanceof CompoundTag) {
|
||||||
CompoundTag enchantmentEntry = new CompoundTag("");
|
CompoundTag enchantmentEntry = new CompoundTag("");
|
||||||
enchantmentEntry.put(new StringTag("id",
|
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
|
||||||
MappingData.oldEnchantmentsIds.get(
|
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
||||||
(short) ((CompoundTag) enchEntry).get("id").getValue()
|
if (newId == null){
|
||||||
)
|
newId = "viaversion:legacy/"+oldId;
|
||||||
));
|
}
|
||||||
enchantmentEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchEntry).get("lvl").getValue()));
|
enchantmentEntry.put(new StringTag("id", newId));
|
||||||
|
enchantmentEntry.put(new ShortTag("lvl", ((Number) ((CompoundTag) enchEntry).get("lvl").getValue()).shortValue()));
|
||||||
enchantments.add(enchantmentEntry);
|
enchantments.add(enchantmentEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,12 +334,15 @@ public class InventoryPackets {
|
|||||||
for (Tag enchEntry : storedEnch) {
|
for (Tag enchEntry : storedEnch) {
|
||||||
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();
|
||||||
|
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
||||||
|
if (newId == null) {
|
||||||
|
newId = "viaversion:legacy/"+oldId;
|
||||||
|
}
|
||||||
enchantmentEntry.put(new StringTag("id",
|
enchantmentEntry.put(new StringTag("id",
|
||||||
MappingData.oldEnchantmentsIds.get(
|
newId
|
||||||
(short) ((CompoundTag) enchEntry).get("id").getValue()
|
|
||||||
)
|
|
||||||
));
|
));
|
||||||
enchantmentEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchEntry).get("lvl").getValue()));
|
enchantmentEntry.put(new ShortTag("lvl", ((Number) ((CompoundTag) enchEntry).get("lvl").getValue()).shortValue()));
|
||||||
newStoredEnch.add(enchantmentEntry);
|
newStoredEnch.add(enchantmentEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,12 +499,15 @@ public class InventoryPackets {
|
|||||||
for (Tag enchantmentEntry : enchantments) {
|
for (Tag enchantmentEntry : enchantments) {
|
||||||
if (enchantmentEntry instanceof CompoundTag) {
|
if (enchantmentEntry instanceof CompoundTag) {
|
||||||
CompoundTag enchEntry = new 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(
|
enchEntry.put(
|
||||||
new ShortTag(
|
new ShortTag(
|
||||||
"id",
|
"id",
|
||||||
MappingData.oldEnchantmentsIds.inverse().get(
|
oldId
|
||||||
(String) ((CompoundTag) enchantmentEntry).get("id").getValue()
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
||||||
@ -515,13 +522,15 @@ public class InventoryPackets {
|
|||||||
ListTag newStoredEnch = new ListTag("StoredEnchantments", CompoundTag.class);
|
ListTag newStoredEnch = new ListTag("StoredEnchantments", CompoundTag.class);
|
||||||
for (Tag enchantmentEntry : storedEnch) {
|
for (Tag enchantmentEntry : storedEnch) {
|
||||||
if (enchantmentEntry instanceof CompoundTag) {
|
if (enchantmentEntry instanceof CompoundTag) {
|
||||||
CompoundTag enchEntry = new 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(
|
enchEntry.put(
|
||||||
new ShortTag(
|
new ShortTag(
|
||||||
"id",
|
"id",
|
||||||
MappingData.oldEnchantmentsIds.inverse().get(
|
oldId
|
||||||
(String) ((CompoundTag) enchantmentEntry).get("id").getValue()
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
||||||
|
Loading…
Reference in New Issue
Block a user