mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-22 12:16:21 +01:00
Update ViaNBT
This commit is contained in:
parent
79a2881a02
commit
c6ea04fd33
@ -78,13 +78,13 @@ public class EnchantmentRewriter {
|
|||||||
|
|
||||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||||
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||||
ListTag enchantments = tag.getListTag(key);
|
ListTag<CompoundTag> enchantments = tag.getListTag(key, CompoundTag.class);
|
||||||
List<Tag> loreToAdd = new ArrayList<>();
|
List<StringTag> loreToAdd = new ArrayList<>();
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
Iterator<Tag> iterator = enchantments.iterator();
|
Iterator<CompoundTag> iterator = enchantments.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
CompoundTag enchantmentEntry = (CompoundTag) iterator.next();
|
CompoundTag enchantmentEntry = iterator.next();
|
||||||
StringTag idTag = enchantmentEntry.getStringTag("id");
|
StringTag idTag = enchantmentEntry.getStringTag("id");
|
||||||
|
|
||||||
String enchantmentId = idTag.getValue();
|
String enchantmentId = idTag.getValue();
|
||||||
@ -123,9 +123,9 @@ public class EnchantmentRewriter {
|
|||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag loreTag = display.getListTag("Lore");
|
ListTag<StringTag> loreTag = display.getListTag("Lore", StringTag.class);
|
||||||
if (loreTag == null) {
|
if (loreTag == null) {
|
||||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
display.put("Lore", loreTag = new ListTag<>(StringTag.class));
|
||||||
} else {
|
} else {
|
||||||
// Save original lore
|
// Save original lore
|
||||||
itemRewriter.saveListTag(display, loreTag, "Lore");
|
itemRewriter.saveListTag(display, loreTag, "Lore");
|
||||||
|
@ -60,15 +60,10 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
name.setValue(newValue);
|
name.setValue(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag lore = display.getListTag("Lore");
|
ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
|
||||||
if (lore != null) {
|
if (lore != null) {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (Tag loreEntryTag : lore) {
|
for (StringTag loreEntry : lore) {
|
||||||
if (!(loreEntryTag instanceof StringTag)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringTag loreEntry = (StringTag) loreEntryTag;
|
|
||||||
String newValue = protocol.getTranslatableRewriter().processText(loreEntry.getValue()).toString();
|
String newValue = protocol.getTranslatableRewriter().processText(loreEntry.getValue()).toString();
|
||||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||||
// Backup original lore before doing any modifications
|
// Backup original lore before doing any modifications
|
||||||
|
@ -62,17 +62,11 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void saveListTag(CompoundTag displayTag, ListTag original, String name) {
|
protected void saveListTag(CompoundTag displayTag, ListTag<?> original, String name) {
|
||||||
// Multiple places might try to backup data
|
// Multiple places might try to backup data
|
||||||
String backupName = nbtTagName + "|o" + name;
|
String backupName = nbtTagName + "|o" + name;
|
||||||
if (!displayTag.contains(backupName)) {
|
if (!displayTag.contains(backupName)) {
|
||||||
// Clone all tag entries
|
displayTag.put(backupName, original.copy());
|
||||||
ListTag listTag = new ListTag();
|
|
||||||
for (Tag tag : original.getValue()) {
|
|
||||||
listTag.add(tag.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
displayTag.put(backupName, listTag);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +97,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
|||||||
protected void restoreListTag(CompoundTag tag, String tagName) {
|
protected void restoreListTag(CompoundTag tag, String tagName) {
|
||||||
Tag original = tag.remove(nbtTagName + "|o" + tagName);
|
Tag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||||
if (original instanceof ListTag) {
|
if (original instanceof ListTag) {
|
||||||
tag.put(tagName, new ListTag(((ListTag) original).getValue()));
|
tag.put(tagName, ((ListTag<?>) original).copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,23 +47,18 @@ public class LegacyEnchantmentRewriter {
|
|||||||
|
|
||||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||||
ListTag enchantments = tag.getListTag(key);
|
ListTag<CompoundTag> enchantments = tag.getListTag(key, CompoundTag.class);
|
||||||
ListTag remappedEnchantments = new ListTag(CompoundTag.class);
|
ListTag<CompoundTag> remappedEnchantments = new ListTag<>(CompoundTag.class);
|
||||||
List<Tag> lore = new ArrayList<>();
|
List<StringTag> lore = new ArrayList<>();
|
||||||
for (Tag enchantmentEntry : enchantments.copy()) {
|
for (CompoundTag enchantmentEntry : enchantments.copy()) {
|
||||||
if (!(enchantmentEntry instanceof CompoundTag)) {
|
NumberTag idTag = enchantmentEntry.getNumberTag("id");
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompoundTag entryTag = (CompoundTag) enchantmentEntry;
|
|
||||||
NumberTag idTag = entryTag.getNumberTag("id");
|
|
||||||
if (idTag == null) continue;
|
if (idTag == null) continue;
|
||||||
|
|
||||||
short newId = idTag.asShort();
|
short newId = idTag.asShort();
|
||||||
String enchantmentName = enchantmentMappings.get(newId);
|
String enchantmentName = enchantmentMappings.get(newId);
|
||||||
if (enchantmentName != null) {
|
if (enchantmentName != null) {
|
||||||
enchantments.remove(enchantmentEntry);
|
enchantments.remove(enchantmentEntry);
|
||||||
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
||||||
short level = levelTag != null ? levelTag.asShort() : 1;
|
short level = levelTag != null ? levelTag.asShort() : 1;
|
||||||
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
|
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
|
||||||
lore.add(new StringTag(enchantmentName));
|
lore.add(new StringTag(enchantmentName));
|
||||||
@ -99,9 +94,9 @@ public class LegacyEnchantmentRewriter {
|
|||||||
if (display == null) {
|
if (display == null) {
|
||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
ListTag loreTag = display.getListTag("Lore");
|
ListTag<StringTag> loreTag = display.getListTag("Lore", StringTag.class);
|
||||||
if (loreTag == null) {
|
if (loreTag == null) {
|
||||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
display.put("Lore", loreTag = new ListTag<>(StringTag.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
lore.addAll(loreTag.getValue());
|
lore.addAll(loreTag.getValue());
|
||||||
@ -111,21 +106,15 @@ public class LegacyEnchantmentRewriter {
|
|||||||
|
|
||||||
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||||
ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key);
|
ListTag<CompoundTag> enchantments = tag.getListTag(key, CompoundTag.class);
|
||||||
ListTag enchantments = tag.getListTag(key);
|
|
||||||
if (enchantments == null) {
|
if (enchantments == null) {
|
||||||
enchantments = new ListTag(CompoundTag.class);
|
enchantments = new ListTag<>(CompoundTag.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
|
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
|
||||||
for (Tag enchantment : enchantments.copy()) {
|
for (CompoundTag enchantment : enchantments.copy()) {
|
||||||
if (!(enchantment instanceof CompoundTag)) {
|
NumberTag idTag = enchantment.getNumberTag("id");
|
||||||
continue;
|
NumberTag levelTag = enchantment.getNumberTag("lvl");
|
||||||
}
|
|
||||||
|
|
||||||
CompoundTag entryTag = (CompoundTag) enchantment;
|
|
||||||
NumberTag idTag = entryTag.getNumberTag("id");
|
|
||||||
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
|
||||||
short id = idTag != null ? idTag.asShort() : 0;
|
short id = idTag != null ? idTag.asShort() : 0;
|
||||||
short level = levelTag != null ? levelTag.asShort() : 0;
|
short level = levelTag != null ? levelTag.asShort() : 0;
|
||||||
if (id == 0 && level == 0) {
|
if (id == 0 && level == 0) {
|
||||||
@ -143,8 +132,9 @@ public class LegacyEnchantmentRewriter {
|
|||||||
|
|
||||||
CompoundTag display = tag.getCompoundTag("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
// A few null checks just to be safe, though they shouldn't actually be
|
// A few null checks just to be safe, though they shouldn't actually be
|
||||||
ListTag lore = display != null ? display.getListTag("Lore") : null;
|
ListTag<StringTag> lore = display != null ? display.getListTag("Lore", StringTag.class) : null;
|
||||||
for (Tag enchantment : remappedEnchantments.copy()) {
|
ListTag<CompoundTag> remappedEnchantments = tag.remove(nbtTagName + "|" + key);
|
||||||
|
for (CompoundTag enchantment : remappedEnchantments.copy()) {
|
||||||
enchantments.add(enchantment);
|
enchantments.add(enchantment);
|
||||||
if (lore != null && !lore.isEmpty()) {
|
if (lore != null && !lore.isEmpty()) {
|
||||||
lore.remove(lore.get(0));
|
lore.remove(lore.get(0));
|
||||||
|
@ -48,14 +48,11 @@ public class BannerHandler implements BackwardsBlockEntityHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Invert colors
|
// Invert colors
|
||||||
ListTag patternsTag = tag.getListTag("Patterns");
|
ListTag<CompoundTag> patternsTag = tag.getListTag("Patterns", CompoundTag.class);
|
||||||
if (patternsTag != null) {
|
if (patternsTag != null) {
|
||||||
for (Tag pattern : patternsTag) {
|
for (CompoundTag pattern : patternsTag) {
|
||||||
if (!(pattern instanceof CompoundTag)) continue;
|
NumberTag colorTag = pattern.getNumberTag("Color");
|
||||||
|
pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||||
CompoundTag patternTag = (CompoundTag) pattern;
|
|
||||||
NumberTag colorTag = patternTag.getNumberTag("Color");
|
|
||||||
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
|||||||
addEntries(entry.getKey(), entry.getValue());
|
addEntries(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ListTag blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").get("blockstates");
|
ListTag<StringTag> blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").getListTag("blockstates", StringTag.class);
|
||||||
for (int id = 0; id < blockStates.size(); id++) {
|
for (int id = 0; id < blockStates.size(); id++) {
|
||||||
StringTag state = blockStates.get(id);
|
StringTag state = blockStates.get(id);
|
||||||
String key = state.getValue();
|
String key = state.getValue();
|
||||||
|
@ -597,10 +597,10 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) {
|
private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) {
|
||||||
// The tag was manually created incorrectly so ignore rewriting it
|
// The tag was manually created incorrectly so ignore rewriting it
|
||||||
ListTag blockTag = tag.getListTag(tagName);
|
ListTag<?> blockTag = tag.getListTag(tagName);
|
||||||
if (blockTag == null) return;
|
if (blockTag == null) return;
|
||||||
|
|
||||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
ListTag<StringTag> newCanPlaceOn = new ListTag<>(StringTag.class);
|
||||||
tag.put(extraNbtTag + "|" + tagName, blockTag.copy());
|
tag.put(extraNbtTag + "|" + tagName, blockTag.copy());
|
||||||
for (Tag oldTag : blockTag) {
|
for (Tag oldTag : blockTag) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
@ -611,7 +611,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
newCanPlaceOn.add(new StringTag(newValue));
|
newCanPlaceOn.add(new StringTag(newValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newCanPlaceOn.add(oldTag);
|
newCanPlaceOn.add(new StringTag(oldTag.getValue().toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.put(tagName, newCanPlaceOn);
|
tag.put(tagName, newCanPlaceOn);
|
||||||
@ -620,19 +620,14 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
//TODO un-ugly all of this
|
//TODO un-ugly all of this
|
||||||
private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) {
|
private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) {
|
||||||
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
||||||
ListTag enchantments = tag.getListTag(key);
|
ListTag<CompoundTag> enchantments = tag.getListTag(key, CompoundTag.class);
|
||||||
if (enchantments == null) return;
|
if (enchantments == null) return;
|
||||||
|
|
||||||
ListTag noMapped = new ListTag(CompoundTag.class);
|
ListTag<CompoundTag> noMapped = new ListTag<>(CompoundTag.class);
|
||||||
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
ListTag<CompoundTag> newEnchantments = new ListTag<>(CompoundTag.class);
|
||||||
List<Tag> lore = new ArrayList<>();
|
List<StringTag> lore = new ArrayList<>();
|
||||||
boolean hasValidEnchants = false;
|
boolean hasValidEnchants = false;
|
||||||
for (Tag enchantmentEntryTag : enchantments.copy()) {
|
for (CompoundTag enchantmentEntry : enchantments.copy()) {
|
||||||
if (!(enchantmentEntryTag instanceof CompoundTag)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
|
|
||||||
StringTag idTag = enchantmentEntry.getStringTag("id");
|
StringTag idTag = enchantmentEntry.getStringTag("id");
|
||||||
if (idTag == null) {
|
if (idTag == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -720,13 +715,13 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag loreTag = display.getListTag("Lore");
|
ListTag<StringTag> loreTag = display.getListTag("Lore", StringTag.class);
|
||||||
if (loreTag == null) {
|
if (loreTag == null) {
|
||||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
display.put("Lore", loreTag = new ListTag<>(StringTag.class));
|
||||||
tag.put(extraNbtTag + "|DummyLore", new ByteTag());
|
tag.put(extraNbtTag + "|DummyLore", new ByteTag());
|
||||||
} else if (!loreTag.isEmpty()) {
|
} else if (!loreTag.isEmpty()) {
|
||||||
ListTag oldLore = new ListTag(StringTag.class);
|
ListTag<StringTag> oldLore = new ListTag<>(StringTag.class);
|
||||||
for (Tag value : loreTag) {
|
for (StringTag value : loreTag) {
|
||||||
oldLore.add(value.copy());
|
oldLore.add(value.copy());
|
||||||
}
|
}
|
||||||
tag.put(extraNbtTag + "|OldLore", oldLore);
|
tag.put(extraNbtTag + "|OldLore", oldLore);
|
||||||
@ -854,11 +849,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) {
|
private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) {
|
||||||
if (tag.getListTag(tagName) == null) return;
|
if (tag.getListTag(tagName) == null) return;
|
||||||
|
|
||||||
ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName);
|
ListTag<?> blockTag = tag.remove(extraNbtTag + "|" + tagName);
|
||||||
if (blockTag != null) {
|
if (blockTag != null) {
|
||||||
tag.put(tagName, blockTag.copy());
|
tag.put(tagName, blockTag.copy());
|
||||||
} else if ((blockTag = tag.getListTag(tagName)) != null) {
|
} else if ((blockTag = tag.getListTag(tagName)) != null) {
|
||||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
ListTag<StringTag> newCanPlaceOn = new ListTag<>(StringTag.class);
|
||||||
for (Tag oldTag : blockTag) {
|
for (Tag oldTag : blockTag) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
String oldId = Key.stripMinecraftNamespace(value.toString());
|
String oldId = Key.stripMinecraftNamespace(value.toString());
|
||||||
@ -884,10 +879,10 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
private void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnch) {
|
private void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnch) {
|
||||||
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
||||||
ListTag enchantments = tag.getListTag(storedEnch ? key : "ench");
|
ListTag<CompoundTag> enchantments = tag.getListTag(storedEnch ? key : "ench", CompoundTag.class);
|
||||||
if (enchantments == null) return;
|
if (enchantments == null) return;
|
||||||
|
|
||||||
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
ListTag<CompoundTag> newEnchantments = new ListTag<>(CompoundTag.class);
|
||||||
boolean dummyEnchant = false;
|
boolean dummyEnchant = false;
|
||||||
if (!storedEnch) {
|
if (!storedEnch) {
|
||||||
Tag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags");
|
Tag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags");
|
||||||
@ -900,12 +895,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Tag enchEntry : enchantments) {
|
for (CompoundTag entryTag : enchantments) {
|
||||||
if (!(enchEntry instanceof CompoundTag)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompoundTag entryTag = (CompoundTag) enchEntry;
|
|
||||||
NumberTag idTag = entryTag.getNumberTag("id");
|
NumberTag idTag = entryTag.getNumberTag("id");
|
||||||
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
CompoundTag enchantmentEntry = new CompoundTag();
|
CompoundTag enchantmentEntry = new CompoundTag();
|
||||||
@ -925,11 +915,12 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
newEnchantments.add(enchantmentEntry);
|
newEnchantments.add(enchantmentEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag noMapped = tag.remove(extraNbtTag + "|Enchantments");
|
ListTag<CompoundTag> noMapped = tag.getListTag(extraNbtTag + "|Enchantments", CompoundTag.class);
|
||||||
if (noMapped instanceof ListTag) {
|
if (noMapped != null) {
|
||||||
for (Tag value : ((ListTag) noMapped)) {
|
for (CompoundTag value : noMapped) {
|
||||||
newEnchantments.add(value);
|
newEnchantments.add(value);
|
||||||
}
|
}
|
||||||
|
tag.remove(extraNbtTag + "|Enchantments");
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag display = tag.getCompoundTag("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
@ -937,14 +928,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag oldLore = tag.remove(extraNbtTag + "|OldLore");
|
ListTag<StringTag> oldLore = tag.getListTag(extraNbtTag + "|OldLore", StringTag.class);
|
||||||
if (oldLore instanceof ListTag) {
|
if (oldLore != null) {
|
||||||
ListTag lore = display.getListTag("Lore");
|
ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
|
||||||
if (lore == null) {
|
if (lore == null) {
|
||||||
tag.put("Lore", lore = new ListTag());
|
tag.put("Lore", lore = new ListTag<>(StringTag.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
lore.setValue(((ListTag) oldLore).getValue());
|
lore.setValue(oldLore.getValue());
|
||||||
|
tag.remove(extraNbtTag + "|OldLore");
|
||||||
} else if (tag.remove(extraNbtTag + "|DummyLore") != null) {
|
} else if (tag.remove(extraNbtTag + "|DummyLore") != null) {
|
||||||
display.remove("Lore");
|
display.remove("Lore");
|
||||||
if (display.isEmpty()) {
|
if (display.isEmpty()) {
|
||||||
@ -969,14 +961,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
blockEntityTag.putInt("Base", 15 - base.asInt()); // Invert color id
|
blockEntityTag.putInt("Base", 15 - base.asInt()); // Invert color id
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag patterns = blockEntityTag.getListTag("Patterns");
|
ListTag<CompoundTag> patterns = blockEntityTag.getListTag("Patterns", CompoundTag.class);
|
||||||
if (patterns != null) {
|
if (patterns != null) {
|
||||||
for (Tag pattern : patterns) {
|
for (CompoundTag pattern : patterns) {
|
||||||
if (!(pattern instanceof CompoundTag)) continue;
|
NumberTag colorTag = pattern.getNumberTag("Color");
|
||||||
|
pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||||
CompoundTag patternTag = (CompoundTag) pattern;
|
|
||||||
NumberTag colorTag = patternTag.getNumberTag("Color");
|
|
||||||
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,17 +473,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
CompoundTag display;
|
CompoundTag display;
|
||||||
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
||||||
ListTag lore = display.getListTag("Lore");
|
ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
|
||||||
if (lore != null) {
|
if (lore != null) {
|
||||||
saveListTag(display, lore, "Lore");
|
saveListTag(display, lore, "Lore");
|
||||||
|
|
||||||
for (Tag loreEntry : lore) {
|
for (StringTag loreEntry : lore) {
|
||||||
if (!(loreEntry instanceof StringTag)) continue;
|
String value = loreEntry.getValue();
|
||||||
|
|
||||||
StringTag loreEntryTag = (StringTag) loreEntry;
|
|
||||||
String value = loreEntryTag.getValue();
|
|
||||||
if (value != null && !value.isEmpty()) {
|
if (value != null && !value.isEmpty()) {
|
||||||
loreEntryTag.setValue(ComponentUtil.jsonToLegacy(value));
|
loreEntry.setValue(ComponentUtil.jsonToLegacy(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,13 +499,10 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
CompoundTag display;
|
CompoundTag display;
|
||||||
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
||||||
// Transform to json if no backup tag is found (else process that in the super method)
|
// Transform to json if no backup tag is found (else process that in the super method)
|
||||||
ListTag lore = display.getListTag("Lore");
|
ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
|
||||||
if (lore != null && !hasBackupTag(display, "Lore")) {
|
if (lore != null && !hasBackupTag(display, "Lore")) {
|
||||||
for (Tag loreEntry : lore) {
|
for (StringTag loreEntry : lore) {
|
||||||
if (loreEntry instanceof StringTag) {
|
loreEntry.setValue(ComponentUtil.legacyToJsonString(loreEntry.getValue()));
|
||||||
StringTag loreEntryTag = (StringTag) loreEntry;
|
|
||||||
loreEntryTag.setValue(ComponentUtil.legacyToJsonString(loreEntryTag.getValue()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,16 +309,11 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
// Handle hover event changes in written book pages
|
// Handle hover event changes in written book pages
|
||||||
if (item.identifier() == 759 && tag != null) {
|
if (item.identifier() == 759 && tag != null) {
|
||||||
ListTag pagesTag = tag.getListTag("pages");
|
ListTag<StringTag> pagesTag = tag.getListTag("pages", StringTag.class);
|
||||||
if (pagesTag != null) {
|
if (pagesTag != null) {
|
||||||
for (Tag page : pagesTag) {
|
for (StringTag page : pagesTag) {
|
||||||
if (!(page instanceof StringTag)) {
|
JsonElement jsonElement = protocol.getTranslatableRewriter().processText(page.getValue());
|
||||||
continue;
|
page.setValue(jsonElement.toString());
|
||||||
}
|
|
||||||
|
|
||||||
StringTag pageTag = (StringTag) page;
|
|
||||||
JsonElement jsonElement = protocol.getTranslatableRewriter().processText(pageTag.getValue());
|
|
||||||
pageTag.setValue(jsonElement.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
|||||||
CompoundTag properties = skullOwnerTag.getCompoundTag("Properties");
|
CompoundTag properties = skullOwnerTag.getCompoundTag("Properties");
|
||||||
if (properties == null) return;
|
if (properties == null) return;
|
||||||
|
|
||||||
ListTag textures = properties.getListTag("textures");
|
ListTag<CompoundTag> textures = properties.getListTag("textures", CompoundTag.class);
|
||||||
if (textures == null) return;
|
if (textures == null) return;
|
||||||
|
|
||||||
CompoundTag first = !textures.isEmpty() ? textures.get(0) : null;
|
CompoundTag first = !textures.isEmpty() ? textures.get(0) : null;
|
||||||
|
@ -76,13 +76,12 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
if (wrapper.user().getProtocolInfo().getProtocolVersion() <= ProtocolVersion.v1_15_2.getVersion()) {
|
if (wrapper.user().getProtocolInfo().getProtocolVersion() <= ProtocolVersion.v1_15_2.getVersion()) {
|
||||||
// Store biomes for <1.16 client handling
|
// Store biomes for <1.16 client handling
|
||||||
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||||
ListTag biomes = biomeRegistry.get("value");
|
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class);
|
BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class);
|
||||||
biomeStorage.clear();
|
biomeStorage.clear();
|
||||||
for (Tag biome : biomes) {
|
for (CompoundTag biome : biomes) {
|
||||||
CompoundTag biomeCompound = (CompoundTag) biome;
|
StringTag name = biome.get("name");
|
||||||
StringTag name = biomeCompound.get("name");
|
NumberTag id = biome.get("id");
|
||||||
NumberTag id = biomeCompound.get("id");
|
|
||||||
biomeStorage.addBiome(name.getValue(), id.asInt());
|
biomeStorage.addBiome(name.getValue(), id.asInt());
|
||||||
}
|
}
|
||||||
} else if (!warned) {
|
} else if (!warned) {
|
||||||
|
@ -85,9 +85,9 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||||
ListTag biomes = biomeRegistry.get("value");
|
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (Tag biome : biomes) {
|
for (CompoundTag biome : biomes) {
|
||||||
CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
CompoundTag biomeCompound = biome.get("element");
|
||||||
StringTag category = biomeCompound.get("category");
|
StringTag category = biomeCompound.get("category");
|
||||||
if (category.getValue().equalsIgnoreCase("underground")) {
|
if (category.getValue().equalsIgnoreCase("underground")) {
|
||||||
category.setValue("none");
|
category.setValue("none");
|
||||||
@ -95,9 +95,9 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag dimensionRegistry = registry.get("minecraft:dimension_type");
|
CompoundTag dimensionRegistry = registry.get("minecraft:dimension_type");
|
||||||
ListTag dimensions = dimensionRegistry.get("value");
|
ListTag<CompoundTag> dimensions = dimensionRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (Tag dimension : dimensions) {
|
for (CompoundTag dimension : dimensions) {
|
||||||
CompoundTag dimensionCompound = ((CompoundTag) dimension).get("element");
|
CompoundTag dimensionCompound = dimension.get("element");
|
||||||
reduceExtendedHeight(dimensionCompound, false);
|
reduceExtendedHeight(dimensionCompound, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,9 +62,9 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||||
final ListTag biomes = biomeRegistry.get("value");
|
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (final Tag biome : biomes.getValue()) {
|
for (final CompoundTag biome : biomes) {
|
||||||
final CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
final CompoundTag biomeCompound = biome.get("element");
|
||||||
final StringTag category = biomeCompound.get("category");
|
final StringTag category = biomeCompound.get("category");
|
||||||
if (category.getValue().equals("mountain")) {
|
if (category.getValue().equals("mountain")) {
|
||||||
category.setValue("extreme_hills");
|
category.setValue("extreme_hills");
|
||||||
|
@ -102,10 +102,10 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
wrapper.passthrough(Type.VAR_INT); // Slot comes first
|
wrapper.passthrough(Type.VAR_INT); // Slot comes first
|
||||||
|
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
ListTag pagesTag;
|
ListTag<StringTag> pagesTag;
|
||||||
StringTag titleTag = null;
|
StringTag titleTag = null;
|
||||||
// Sanity checks
|
// Sanity checks
|
||||||
if (tag == null || (pagesTag = tag.getListTag("pages")) == null
|
if (tag == null || (pagesTag = tag.getListTag("pages", StringTag.class)) == null
|
||||||
|| (signing && (titleTag = tag.getStringTag("title")) == null)) {
|
|| (signing && (titleTag = tag.getStringTag("title")) == null)) {
|
||||||
wrapper.write(Type.VAR_INT, 0); // Pages length
|
wrapper.write(Type.VAR_INT, 0); // Pages length
|
||||||
wrapper.write(Type.BOOLEAN, false); // Optional title
|
wrapper.write(Type.BOOLEAN, false); // Optional title
|
||||||
@ -114,12 +114,12 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
|
|
||||||
// Write pages - limit them first
|
// Write pages - limit them first
|
||||||
if (pagesTag.size() > MAX_PAGES) {
|
if (pagesTag.size() > MAX_PAGES) {
|
||||||
pagesTag = new ListTag(pagesTag.getValue().subList(0, MAX_PAGES));
|
pagesTag = new ListTag<>(pagesTag.getValue().subList(0, MAX_PAGES));
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.write(Type.VAR_INT, pagesTag.size());
|
wrapper.write(Type.VAR_INT, pagesTag.size());
|
||||||
for (Tag pageTag : pagesTag) {
|
for (StringTag pageTag : pagesTag) {
|
||||||
String page = ((StringTag) pageTag).getValue();
|
String page = pageTag.getValue();
|
||||||
// Limit page length
|
// Limit page length
|
||||||
if (page.length() > MAX_PAGE_LENGTH) {
|
if (page.length() > MAX_PAGE_LENGTH) {
|
||||||
page = page.substring(0, MAX_PAGE_LENGTH);
|
page = page.substring(0, MAX_PAGE_LENGTH);
|
||||||
|
@ -23,7 +23,6 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
|||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
|
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@ -39,11 +38,10 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
|
|||||||
protected void loadExtras(final CompoundTag data) {
|
protected void loadExtras(final CompoundTag data) {
|
||||||
super.loadExtras(data);
|
super.loadExtras(data);
|
||||||
|
|
||||||
final ListTag chatTypes = VBMappingDataLoader.loadNBT("chat-types-1.19.1.nbt").get("values");
|
final ListTag<CompoundTag> chatTypes = VBMappingDataLoader.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class);
|
||||||
for (final Tag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
final NumberTag idTag = chatType.get("id");
|
||||||
final NumberTag idTag = chatTypeCompound.get("id");
|
defaultChatTypes.put(idTag.asInt(), chatType);
|
||||||
defaultChatTypes.put(idTag.asInt(), chatTypeCompound);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,12 +131,11 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
|||||||
// Cache dimensions and find current dimension
|
// Cache dimensions and find current dimension
|
||||||
final String dimensionKey = wrapper.read(Type.STRING);
|
final String dimensionKey = wrapper.read(Type.STRING);
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag dimensions = ((CompoundTag) registry.get("minecraft:dimension_type")).get("value");
|
final ListTag<CompoundTag> dimensions = ((CompoundTag) registry.get("minecraft:dimension_type")).getListTag("value", CompoundTag.class);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (final Tag dimension : dimensions) {
|
for (final CompoundTag dimension : dimensions) {
|
||||||
final CompoundTag dimensionCompound = (CompoundTag) dimension;
|
final StringTag nameTag = dimension.get("name");
|
||||||
final StringTag nameTag = dimensionCompound.get("name");
|
final CompoundTag dimensionData = dimension.get("element");
|
||||||
final CompoundTag dimensionData = dimensionCompound.get("element");
|
|
||||||
dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.copy());
|
dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.copy());
|
||||||
|
|
||||||
if (!found && nameTag.getValue().equals(dimensionKey)) {
|
if (!found && nameTag.getValue().equals(dimensionKey)) {
|
||||||
@ -150,19 +149,18 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
|||||||
|
|
||||||
// Add biome category and track biomes
|
// Add biome category and track biomes
|
||||||
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||||
final ListTag biomes = biomeRegistry.get("value");
|
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (final Tag biome : biomes.getValue()) {
|
for (final CompoundTag biome : biomes.getValue()) {
|
||||||
final CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
final CompoundTag biomeCompound = biome.get("element");
|
||||||
biomeCompound.putString("category", "none");
|
biomeCompound.putString("category", "none");
|
||||||
}
|
}
|
||||||
tracker(wrapper.user()).setBiomesSent(biomes.size());
|
tracker(wrapper.user()).setBiomesSent(biomes.size());
|
||||||
|
|
||||||
// Cache and remove chat types
|
// Cache and remove chat types
|
||||||
final ListTag chatTypes = ((CompoundTag) registry.remove("minecraft:chat_type")).get("value");
|
final ListTag<CompoundTag> chatTypes = ((CompoundTag) registry.remove("minecraft:chat_type")).getListTag("value", CompoundTag.class);
|
||||||
for (final Tag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
final NumberTag idTag = chatType.get("id");
|
||||||
final NumberTag idTag = chatTypeCompound.get("id");
|
dimensionRegistryStorage.addChatType(idTag.asInt(), chatType);
|
||||||
dimensionRegistryStorage.addChatType(idTag.asInt(), chatTypeCompound);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
map(Type.STRING); // World
|
map(Type.STRING); // World
|
||||||
|
@ -82,9 +82,9 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type");
|
final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type");
|
||||||
final ListTag dimensions = dimensionsHolder.get("value");
|
final ListTag<CompoundTag> dimensions = dimensionsHolder.getListTag("value", CompoundTag.class);
|
||||||
for (final Tag dimension : dimensions) {
|
for (final CompoundTag dimension : dimensions) {
|
||||||
removeTagPrefix(((CompoundTag) dimension).get("element"));
|
removeTagPrefix(dimension.get("element"));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
|
removeTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
|
||||||
|
@ -82,11 +82,10 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
|||||||
final ChatTypeStorage1_19_3 chatTypeStorage = wrapper.user().get(ChatTypeStorage1_19_3.class);
|
final ChatTypeStorage1_19_3 chatTypeStorage = wrapper.user().get(ChatTypeStorage1_19_3.class);
|
||||||
chatTypeStorage.clear();
|
chatTypeStorage.clear();
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag chatTypes = registry.getCompoundTag("minecraft:chat_type").get("value");
|
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
|
||||||
for (final Tag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
final NumberTag idTag = chatType.get("id");
|
||||||
final NumberTag idTag = chatTypeCompound.get("id");
|
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
||||||
chatTypeStorage.addChatType(idTag.asInt(), chatTypeCompound);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
|
@ -68,9 +68,9 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
|||||||
registry.remove("minecraft:damage_type");
|
registry.remove("minecraft:damage_type");
|
||||||
|
|
||||||
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||||
final ListTag biomes = biomeRegistry.get("value");
|
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (final Tag biomeTag : biomes) {
|
for (final CompoundTag biomeTag : biomes) {
|
||||||
final CompoundTag biomeData = ((CompoundTag) biomeTag).get("element");
|
final CompoundTag biomeData = biomeTag.get("element");
|
||||||
final NumberTag hasPrecipitation = biomeData.get("has_precipitation");
|
final NumberTag hasPrecipitation = biomeData.get("has_precipitation");
|
||||||
biomeData.putString("precipitation", hasPrecipitation.asByte() == 1 ? "rain" : "none");
|
biomeData.putString("precipitation", hasPrecipitation.asByte() == 1 ? "rain" : "none");
|
||||||
}
|
}
|
||||||
|
@ -218,13 +218,13 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeMessages(final CompoundTag frontText, final CompoundTag tag, final boolean filtered) {
|
private void writeMessages(final CompoundTag frontText, final CompoundTag tag, final boolean filtered) {
|
||||||
final ListTag messages = frontText.getListTag(filtered ? "filtered_messages" : "messages");
|
final ListTag<StringTag> messages = frontText.getListTag(filtered ? "filtered_messages" : "messages", StringTag.class);
|
||||||
if (messages == null) {
|
if (messages == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final Tag message : messages) {
|
for (final StringTag message : messages) {
|
||||||
tag.put((filtered ? "FilteredText" : "Text") + ++i, message);
|
tag.put((filtered ? "FilteredText" : "Text") + ++i, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,20 +80,20 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
|
|
||||||
final ListTag values;
|
final ListTag<CompoundTag> values;
|
||||||
// A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing
|
// A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing
|
||||||
// on a 1.19.4 client there is an exception, so in case the 1.20 server doesn't send the element we put in an original 1.20 element
|
// on a 1.19.4 client there is an exception, so in case the 1.20 server doesn't send the element we put in an original 1.20 element
|
||||||
final CompoundTag trimPatternTag = registry.getCompoundTag("minecraft:trim_pattern");
|
final CompoundTag trimPatternTag = registry.getCompoundTag("minecraft:trim_pattern");
|
||||||
if (trimPatternTag != null) {
|
if (trimPatternTag != null) {
|
||||||
values = trimPatternTag.getListTag("value");
|
values = trimPatternTag.getListTag("value", CompoundTag.class);
|
||||||
} else {
|
} else {
|
||||||
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy();
|
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy();
|
||||||
registry.put("minecraft:trim_pattern", trimPatternRegistry);
|
registry.put("minecraft:trim_pattern", trimPatternRegistry);
|
||||||
values = trimPatternRegistry.get("value");
|
values = trimPatternRegistry.get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Tag entry : values) {
|
for (final CompoundTag entry : values) {
|
||||||
final CompoundTag element = ((CompoundTag) entry).get("element");
|
final CompoundTag element = entry.get("element");
|
||||||
final StringTag templateItem = element.get("template_item");
|
final StringTag templateItem = element.get("template_item");
|
||||||
if (newTrimPatterns.contains(Key.stripMinecraftNamespace(templateItem.getValue()))) {
|
if (newTrimPatterns.contains(Key.stripMinecraftNamespace(templateItem.getValue()))) {
|
||||||
templateItem.setValue("minecraft:spire_armor_trim_smithing_template");
|
templateItem.setValue("minecraft:spire_armor_trim_smithing_template");
|
||||||
|
@ -103,11 +103,10 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
chatTypeStorage.clear();
|
chatTypeStorage.clear();
|
||||||
|
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag chatTypes = registry.getCompoundTag("minecraft:chat_type").get("value");
|
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
|
||||||
for (final Tag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
final NumberTag idTag = chatType.get("id");
|
||||||
final NumberTag idTag = chatTypeCompound.get("id");
|
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
||||||
chatTypeStorage.addChatType(idTag.asInt(), chatTypeCompound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace with 1.19 chat types
|
// Replace with 1.19 chat types
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
projectVersion=4.9.2
|
projectVersion=4.9.3-SNAPSHOT
|
||||||
|
|
||||||
# Smile emoji
|
# Smile emoji
|
||||||
mcVersions=1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10
|
mcVersions=1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10
|
||||||
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
# ViaVersion
|
# ViaVersion
|
||||||
viaver = "4.9.3-SNAPSHOT"
|
viaver = "4.9.4-SNAPSHOT"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
netty = "4.0.20.Final"
|
netty = "4.0.20.Final"
|
||||||
|
Loading…
Reference in New Issue
Block a user