mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-28 02:48:14 -05:00
Update #48 - Added some features from OptiFine
This commit is contained in:
96
sources/main/java/net/optifine/util/TextureUtils.java
Normal file
96
sources/main/java/net/optifine/util/TextureUtils.java
Normal file
@ -0,0 +1,96 @@
|
||||
package net.optifine.util;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.optifine.BetterGrass;
|
||||
import net.optifine.BetterSnow;
|
||||
import net.optifine.Config;
|
||||
import net.optifine.CustomItems;
|
||||
import net.optifine.CustomSky;
|
||||
import net.optifine.SmartLeaves;
|
||||
|
||||
public class TextureUtils {
|
||||
|
||||
public static String fixResourcePath(String path, String basePath) {
|
||||
String s = "assets/minecraft/";
|
||||
|
||||
if (path.startsWith(s)) {
|
||||
path = path.substring(s.length());
|
||||
return path;
|
||||
} else if (path.startsWith("./")) {
|
||||
path = path.substring(2);
|
||||
|
||||
if (!basePath.endsWith("/")) {
|
||||
basePath = basePath + "/";
|
||||
}
|
||||
|
||||
path = basePath + path;
|
||||
return path;
|
||||
} else {
|
||||
if (path.startsWith("/~")) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
|
||||
String s1 = "mcpatcher/";
|
||||
|
||||
if (path.startsWith("~/")) {
|
||||
path = path.substring(2);
|
||||
path = s1 + path;
|
||||
return path;
|
||||
} else if (path.startsWith("/")) {
|
||||
path = s1 + path.substring(1);
|
||||
return path;
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getBasePath(String path) {
|
||||
int i = path.lastIndexOf(47);
|
||||
return i < 0 ? "" : path.substring(0, i);
|
||||
}
|
||||
|
||||
public static void registerResourceListener() {
|
||||
IResourceManager iresourcemanager = Minecraft.getMinecraft().getResourceManager();
|
||||
if (iresourcemanager instanceof IReloadableResourceManager) {
|
||||
IReloadableResourceManager ireloadableresourcemanager = (IReloadableResourceManager) iresourcemanager;
|
||||
IResourceManagerReloadListener iresourcemanagerreloadlistener = new IResourceManagerReloadListener() {
|
||||
public void onResourceManagerReload(IResourceManager var1) {
|
||||
TextureUtils.resourcesReloaded(var1);
|
||||
}
|
||||
};
|
||||
ireloadableresourcemanager.registerReloadListener(iresourcemanagerreloadlistener);
|
||||
}
|
||||
}
|
||||
|
||||
public static void resourcesReloaded(IResourceManager rm) {
|
||||
if (Minecraft.getMinecraft().getTextureMapBlocks() != null) {
|
||||
Config.dbg("*** Reloading custom textures ***");
|
||||
CustomSky.reset();
|
||||
// TextureAnimations.reset();
|
||||
// update();
|
||||
// NaturalTextures.update();
|
||||
BetterGrass.update();
|
||||
BetterSnow.update();
|
||||
// TextureAnimations.update();
|
||||
// CustomColors.update();
|
||||
CustomSky.update();
|
||||
// RandomEntities.update();
|
||||
CustomItems.updateModels();
|
||||
// CustomEntityModels.update();
|
||||
// Shaders.resourcesReloaded();
|
||||
// Lang.resourcesReloaded();
|
||||
// Config.updateTexturePackClouds();
|
||||
SmartLeaves.updateLeavesModels();
|
||||
// CustomPanorama.update();
|
||||
// CustomGuis.update();
|
||||
// LayerMooshroomMushroom.update();
|
||||
// CustomLoadingScreens.update();
|
||||
// CustomBlockLayers.update();
|
||||
Minecraft.getMinecraft().getTextureManager().tick();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user