mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-22 13:19:52 +00:00
Improve perf of TextureType.exists (#97)
This commit is contained in:
1 parent
539ddce15f
commit
886c8819c0
2 files changed
+24
-2
No files matched your search
@@ -6,6 +6,10 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.resources.FallbackResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourcePack;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -384,11 +388,25 @@ public enum TextureType {
|
||||
return CUSTOM;
|
||||
}
|
||||
|
||||
// This is ugly, but faster than class.getResource
|
||||
private static boolean exists(String modid, String path, String postfix) {
|
||||
ResourceLocation rl = new ResourceLocation(modid, "textures/blocks/" + path + postfix + ".png");
|
||||
|
||||
final IResourceManager resMan = Minecraft.getMinecraft().getResourceManager();
|
||||
if (resMan instanceof SimpleReloadableResourceManager simple) {
|
||||
FallbackResourceManager fallback = (FallbackResourceManager)simple.domainResourceManagers.get(rl.getResourceDomain());
|
||||
if (fallback != null) {
|
||||
for (Object obj : fallback.resourcePacks) {
|
||||
if (obj instanceof IResourcePack rp && rp.resourceExists(rl)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback
|
||||
try {
|
||||
Minecraft.getMinecraft().getResourceManager().getAllResources(rl);
|
||||
resMan.getAllResources(rl);
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
|
||||
@@ -5,3 +5,7 @@ public net.minecraft.client.renderer.Tessellator field_78417_x
|
||||
|
||||
# GUI stuff for item scale
|
||||
protected net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet/minecraft/inventory/Slot;)V # drawSlot
|
||||
|
||||
# Checking if a resource exists
|
||||
public net.minecraft.client.resources.SimpleReloadableResourceManager field_110548_a # domainResourceManagers
|
||||
public net.minecraft.client.resources.FallbackResourceManager field_110540_a # resourcePacks
|
||||
Reference in new issue
Block a user