From 9be61340736c00b652f225aaf45ba97a9a73b3d5 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:55:23 -0400 Subject: [PATCH] Remove obsolete resource pack code --- .../resources/CachedResourcePath.java | 108 ------------------ .../resources/NewResourcePackAdapter.java | 17 --- 2 files changed, 125 deletions(-) delete mode 100644 common/src/main/java/org/embeddedt/modernfix/resources/CachedResourcePath.java delete mode 100644 common/src/main/java/org/embeddedt/modernfix/resources/NewResourcePackAdapter.java diff --git a/common/src/main/java/org/embeddedt/modernfix/resources/CachedResourcePath.java b/common/src/main/java/org/embeddedt/modernfix/resources/CachedResourcePath.java deleted file mode 100644 index f82f0521..00000000 --- a/common/src/main/java/org/embeddedt/modernfix/resources/CachedResourcePath.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.embeddedt.modernfix.resources; - -import com.google.common.base.Splitter; -import com.google.common.collect.Interner; -import com.google.common.collect.Interners; -import org.embeddedt.modernfix.util.FileUtil; - -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collection; - -public class CachedResourcePath { - private final String[] pathComponents; - - public static final Interner PATH_COMPONENT_INTERNER = Interners.newStrongInterner(); - private static final Splitter SLASH_SPLITTER = Splitter.on('/'); - public static final String[] NO_PREFIX = new String[0]; - - public CachedResourcePath(String[] prefix, Path path) { - this(prefix, path, path.getNameCount(), true); - } - - public CachedResourcePath(String s) { - // normalize so we can guarantee there are no empty sections - this(NO_PREFIX, SLASH_SPLITTER.splitToList(FileUtil.normalize(s)), false); - } - - public CachedResourcePath(String[] prefixElements, Collection collection, boolean intern) { - this(prefixElements, collection, collection.size(), intern); - } - - public CachedResourcePath(String[] prefixElements, Iterable path, int count, boolean intern) { - String[] components = new String[prefixElements.length + count]; - int i = 0; - while(i < prefixElements.length) { - components[i] = intern ? PATH_COMPONENT_INTERNER.intern(prefixElements[i]) : prefixElements[i]; - i++; - } - for(Object component : path) { - String s = component.toString(); - if(s.length() == 0) - continue; - components[i] = intern ? PATH_COMPONENT_INTERNER.intern(s) : s; - i++; - } - pathComponents = components; - } - - public CachedResourcePath(String[] prefixElements, CachedResourcePath other) { - String[] components = new String[prefixElements.length + other.pathComponents.length]; - int i = 0; - while(i < prefixElements.length) { - components[i] = PATH_COMPONENT_INTERNER.intern(prefixElements[i]); - i++; - } - System.arraycopy(other.pathComponents, 0, components, i, other.pathComponents.length); - pathComponents = components; - } - - /** - * DOES NOT INTERN! - */ - public CachedResourcePath(String[] pathComponents) { - for(String s : pathComponents) { - if(s.length() == 0) { - // reconstruct the whole array skipping blanks. inefficient, but should not be the common case - pathComponents = Arrays.stream(pathComponents).filter(comp -> comp.length() > 0).toArray(String[]::new); - break; - } - } - this.pathComponents = pathComponents; - } - - @Override - public int hashCode() { - return Arrays.hashCode(pathComponents); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - CachedResourcePath that = (CachedResourcePath) o; - return Arrays.equals(pathComponents, that.pathComponents); - } - - public String getFileName() { - return pathComponents[pathComponents.length - 1]; - } - - public int getNameCount() { - return pathComponents.length; - } - - public String getNameAt(int i) { - return pathComponents[i]; - } - - public String getFullPath(int startIndex) { - StringBuilder sb = new StringBuilder(); - for(int i = startIndex; i < pathComponents.length; i++) { - sb.append(pathComponents[i]); - if(i != (pathComponents.length - 1)) - sb.append('/'); - } - return sb.toString(); - } -} diff --git a/common/src/main/java/org/embeddedt/modernfix/resources/NewResourcePackAdapter.java b/common/src/main/java/org/embeddedt/modernfix/resources/NewResourcePackAdapter.java deleted file mode 100644 index fb1d16a6..00000000 --- a/common/src/main/java/org/embeddedt/modernfix/resources/NewResourcePackAdapter.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.embeddedt.modernfix.resources; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.PackResources; -import net.minecraft.server.packs.resources.IoSupplier; - -import java.io.InputStream; -import java.util.Collection; -import java.util.function.Function; - -public class NewResourcePackAdapter { - public static void sendToOutput(Function> streamCreator, PackResources.ResourceOutput output, Collection locations) { - for(ResourceLocation rl : locations) { - output.accept(rl, streamCreator.apply(rl)); - } - } -}