Fix resource packs

This commit is contained in:
PeytonPlayz595 2024-01-26 06:55:38 +00:00
parent 6e6ac339dc
commit 855d8088a9
58 changed files with 73280 additions and 73275 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -1 +0,0 @@
This is a test file, it does nothing, I'm just trying to get CustomSky's to work with Resource Packs...

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,7 @@ import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.PeytonPlayz585.shadow.reflections.Reflector; import net.PeytonPlayz585.shadow.reflections.Reflector;
@ -24,6 +25,8 @@ import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.client.resources.ResourcePackRepository.Entry; import net.minecraft.client.resources.ResourcePackRepository.Entry;
import net.lax1dude.eaglercraft.v1_8.internal.vfs.SYS;
public class Config { public class Config {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@ -432,18 +435,14 @@ public class Config {
} }
public static boolean hasResource(ResourceLocation p_hasResource_0_) { public static boolean hasResource(ResourceLocation p_hasResource_0_) {
IResourcePack iresourcepack = getDefiningResourcePack(p_hasResource_0_); for (IResourcePack resourcePack : getResourcePacks()) {
return iresourcepack != null; if (resourcePack.resourceExists(p_hasResource_0_)) {
return true;
}
} }
public static boolean hasResource(IResourceManager p_hasResource_0_, ResourceLocation p_hasResource_1_) {
try {
IResource iresource = p_hasResource_0_.getResource(p_hasResource_1_);
return iresource != null;
} catch (IOException var3) {
return false; return false;
} }
}
public static IResourcePack getDefiningResourcePack(ResourceLocation p_getDefiningResourcePack_0_) { public static IResourcePack getDefiningResourcePack(ResourceLocation p_getDefiningResourcePack_0_) {
ResourcePackRepository resourcepackrepository = Minecraft.getMinecraft().getResourcePackRepository(); ResourcePackRepository resourcepackrepository = Minecraft.getMinecraft().getResourcePackRepository();
@ -503,13 +502,23 @@ public class Config {
return airesourcepack; return airesourcepack;
} }
public static InputStream getResourceStream(ResourceLocation p_getResourceStream_0_) throws IOException { public static InputStream getResourceStream(ResourceLocation p_getResourceStream_1_) throws IOException {
return getResourceStream(Minecraft.getMinecraft().getResourceManager(), p_getResourceStream_0_); IResourceManager p_getResourceStream_0_ = Minecraft.getMinecraft().getResourceManager();
IResource defaultResource = p_getResourceStream_0_.getResource(p_getResourceStream_1_);
if (defaultResource != null) {
return defaultResource.getInputStream();
} }
public static InputStream getResourceStream(IResourceManager p_getResourceStream_0_, ResourceLocation p_getResourceStream_1_) throws IOException { Set<String> resourceDomains = p_getResourceStream_0_.getResourceDomains();
IResource iresource = p_getResourceStream_0_.getResource(p_getResourceStream_1_); for (String resourceDomain : resourceDomains) {
return iresource == null ? null : iresource.getInputStream(); IResource resource = p_getResourceStream_0_.getResource(new ResourceLocation(resourceDomain, p_getResourceStream_1_.getResourcePath()));
if (resource != null) {
return resource.getInputStream();
}
}
return null;
} }
public static int intHash(int p_intHash_0_) { public static int intHash(int p_intHash_0_) {

View File

@ -49,7 +49,6 @@ public class CustomSky {
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(inputstream); properties.load(inputstream);
inputstream.close(); inputstream.close();
//Config.dbg("CustomSky properties: " + s2);
String s3 = s1 + k + ".png"; String s3 = s1 + k + ".png";
CustomSkyLayer customskylayer = new CustomSkyLayer(properties, s3); CustomSkyLayer customskylayer = new CustomSkyLayer(properties, s3);
@ -57,9 +56,7 @@ public class CustomSky {
ResourceLocation resourcelocation1 = new ResourceLocation(customskylayer.source); ResourceLocation resourcelocation1 = new ResourceLocation(customskylayer.source);
ITextureObject itextureobject = TextureUtils.getTexture(resourcelocation1); ITextureObject itextureobject = TextureUtils.getTexture(resourcelocation1);
if (itextureobject == null) { if (itextureobject != null) {
//Config.log("CustomSky: Texture not found: " + resourcelocation1);
} else {
customskylayer.textureId = itextureobject.getGlTextureId(); customskylayer.textureId = itextureobject.getGlTextureId();
list.add(customskylayer); list.add(customskylayer);
inputstream.close(); inputstream.close();
@ -95,7 +92,6 @@ public class CustomSky {
public static void renderSky(World p_renderSky_0_, TextureManager p_renderSky_1_, float p_renderSky_2_, float p_renderSky_3_) { public static void renderSky(World p_renderSky_0_, TextureManager p_renderSky_1_, float p_renderSky_2_, float p_renderSky_3_) {
if (worldSkyLayers != null) { if (worldSkyLayers != null) {
//if (Config.getGameSettings().renderDistanceChunks >= 8) {
int i = p_renderSky_0_.provider.getDimensionId(); int i = p_renderSky_0_.provider.getDimensionId();
if (i >= 0 && i < worldSkyLayers.length) { if (i >= 0 && i < worldSkyLayers.length) {
@ -116,9 +112,8 @@ public class CustomSky {
Blender.clearBlend(p_renderSky_3_); Blender.clearBlend(p_renderSky_3_);
} }
} }
//}
} }
} }
public static boolean hasSkyLayers(World p_hasSkyLayers_0_) { public static boolean hasSkyLayers(World p_hasSkyLayers_0_) {
if (worldSkyLayers == null) { if (worldSkyLayers == null) {

View File

@ -20,7 +20,7 @@ public class FontUtils {
try { try {
ResourceLocation resourcelocation = new ResourceLocation(p_readFontProperties_0_.getResourceDomain(), s2); ResourceLocation resourcelocation = new ResourceLocation(p_readFontProperties_0_.getResourceDomain(), s2);
InputStream inputstream = Config.getResourceStream(Minecraft.getMinecraft().getResourceManager(), resourcelocation); InputStream inputstream = Config.getResourceStream(resourcelocation);
if (inputstream == null) { if (inputstream == null) {
return properties; return properties;
@ -92,7 +92,7 @@ public class FontUtils {
s = s.substring(s1.length()); s = s.substring(s1.length());
s = s2 + s; s = s2 + s;
ResourceLocation resourcelocation = new ResourceLocation(p_getHdFontLocation_0_.getResourceDomain(), s); ResourceLocation resourcelocation = new ResourceLocation(p_getHdFontLocation_0_.getResourceDomain(), s);
return Config.hasResource(Minecraft.getMinecraft().getResourceManager(), resourcelocation) ? resourcelocation : p_getHdFontLocation_0_; return Config.hasResource(resourcelocation) ? resourcelocation : p_getHdFontLocation_0_;
} }
} }
} }

View File

@ -1,12 +1,19 @@
package net.PeytonPlayz585.shadow; package net.PeytonPlayz585.shadow;
import java.io.*;
import java.util.*;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.SimpleTexture; import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.client.resources.ResourcePackRepository;
public class TextureUtils { public class TextureUtils {
@ -100,16 +107,29 @@ public class TextureUtils {
} }
public static ITextureObject getTexture(ResourceLocation p_getTexture_0_) { public static ITextureObject getTexture(ResourceLocation p_getTexture_0_) {
ITextureObject itextureobject = Config.getTextureManager().getTexture(p_getTexture_0_); TextureManager textureManager = Config.getTextureManager();
ITextureObject itextureobject = textureManager.getTexture(p_getTexture_0_);
if (itextureobject != null) { if (itextureobject != null) {
return itextureobject; return itextureobject;
} else if (!Config.hasResource(p_getTexture_0_)) { } else if (!Config.hasResource(p_getTexture_0_)) {
return null; return null;
} else { } else {
SimpleTexture simpletexture = new SimpleTexture(p_getTexture_0_); for (ResourcePackRepository.Entry resourcePackEntry : Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries()) {
Config.getTextureManager().loadTexture(p_getTexture_0_, simpletexture); IResourcePack resourcePack = resourcePackEntry.getResourcePack();
return simpletexture; try {
InputStream resourceStream = resourcePack.getInputStream(p_getTexture_0_);
if (resourceStream != null) {
itextureobject = new SimpleTexture(p_getTexture_0_);
textureManager.loadTexture(p_getTexture_0_, itextureobject);
return itextureobject;
}
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
} }
} }

View File

@ -2,6 +2,7 @@ package net.minecraft.client.resources;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -161,6 +162,21 @@ public class ResourcePackRepository {
} }
} }
public IResource getResource(ResourceLocation location) {
for (ResourcePackRepository.Entry entry : this.repositoryEntries) {
try {
IResourcePack resourcePack = entry.getResourcePack();
InputStream inputStream = resourcePack.getInputStream(location);
if (inputStream != null) {
return new SimpleResource(entry.getResourcePackName(), location, inputStream, null, null);
}
} catch (IOException e) {
logger.warn("Failed to access resource pack {}", entry.getResourcePackName(), e);
}
}
return null;
}
public class Entry { public class Entry {
private final String resourcePackFile; private final String resourcePackFile;
private IResourcePack reResourcePack; private IResourcePack reResourcePack;