Remove obsolete resource pack code

This commit is contained in:
embeddedt 2025-04-28 18:55:23 -04:00
parent 59e3b83d74
commit 9be6134073
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 0 additions and 125 deletions

View File

@ -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<String> 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 <T> CachedResourcePath(String[] prefixElements, Collection<T> collection, boolean intern) {
this(prefixElements, collection, collection.size(), intern);
}
public <T> CachedResourcePath(String[] prefixElements, Iterable<T> 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();
}
}

View File

@ -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<ResourceLocation, IoSupplier<InputStream>> streamCreator, PackResources.ResourceOutput output, Collection<ResourceLocation> locations) {
for(ResourceLocation rl : locations) {
output.accept(rl, streamCreator.apply(rl));
}
}
}