From 558e1d2fb0df931b6787e1d1de57e1b738289521 Mon Sep 17 00:00:00 2001 From: cpw Date: Thu, 11 Oct 2018 19:35:22 -0400 Subject: [PATCH] ResourceLocation Utils for doing things.. --- .../minecraftforge/fml/ResourceLocationUtils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/net/minecraftforge/fml/ResourceLocationUtils.java diff --git a/src/main/java/net/minecraftforge/fml/ResourceLocationUtils.java b/src/main/java/net/minecraftforge/fml/ResourceLocationUtils.java new file mode 100644 index 000000000..9033460c8 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/ResourceLocationUtils.java @@ -0,0 +1,12 @@ +package net.minecraftforge.fml; + +import com.google.common.base.Joiner; +import net.minecraft.util.ResourceLocation; + +import java.nio.file.Path; + +public class ResourceLocationUtils { + public static ResourceLocation pathToResourceLocation(Path path, int maxDepth) { + return new ResourceLocation(path.getName(0).toString(), Joiner.on("/").join(path.subpath(1, Math.min(maxDepth, path.getNameCount())).iterator())); + } +}