Merge the 1.19 changes into the 1.20 codebase

This commit is contained in:
Zontreck 2024-02-13 22:43:36 -07:00
parent c5637d7c44
commit c3d9096e63
7 changed files with 54 additions and 54 deletions

View file

@ -0,0 +1,45 @@
package dev.zontreck.libzontreck.util;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.ariaslib.util.FileIO;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import java.io.File;
import java.nio.file.Path;
/**
* Provides helpers for reading and writing snbt to file
*/
public class SNbtIo
{
/**
* Read the file at the path, and deserialize from snbt
* @param path The file to load
* @return The deserialized compound tag, or a blank tag
*/
public static CompoundTag loadSnbt(Path path)
{
if(!path.toFile().exists())
return new CompoundTag();
else {
File fi = path.toFile();
try {
return NbtUtils.snbtToStructure(FileIO.readFile(fi.getAbsolutePath()));
} catch (CommandSyntaxException e) {
return new CompoundTag();
}
}
}
/**
* Writes the tag to the file specified
* @param path The file to write
* @param tag The tag to serialize
*/
public static void writeSnbt(Path path, CompoundTag tag)
{
String snbt = NbtUtils.structureToSnbt(tag);
FileIO.writeFile(path.toFile().getAbsolutePath(), snbt);
}
}

View file

@ -4,6 +4,7 @@ import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.lore.ExtraLore;
import dev.zontreck.libzontreck.lore.LoreContainer;
import dev.zontreck.libzontreck.lore.LoreEntry;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
@ -28,7 +29,7 @@ public class CreditsEntry {
public ItemStack compile()
{
ItemStack stack = player.getAsItem("");
stack.setHoverName(Component.literal(name));
stack.setHoverName(ChatHelpers.macro(name));
LoreContainer contain = new LoreContainer(stack);
contain.clear();
LoreEntry.Builder builder = new LoreEntry.Builder();