Merge the 1.19 changes into the 1.20 codebase
This commit is contained in:
parent
c5637d7c44
commit
c3d9096e63
7 changed files with 54 additions and 54 deletions
45
src/main/java/dev/zontreck/libzontreck/util/SNbtIo.java
Normal file
45
src/main/java/dev/zontreck/libzontreck/util/SNbtIo.java
Normal 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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
Reference in a new issue