Use FML functions and FML mod texture static for texture overrides
This commit is contained in:
parent
dcd076728e
commit
1559f77695
1 changed files with 11 additions and 45 deletions
|
@ -11,6 +11,7 @@ package net.minecraft.src.buildcraft.core;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.src.Block;
|
import net.minecraft.src.Block;
|
||||||
|
@ -31,19 +32,10 @@ import net.minecraft.src.forge.NetworkMod;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import cpw.mods.fml.client.SpriteHelper;
|
||||||
|
|
||||||
public class CoreProxy {
|
public class CoreProxy {
|
||||||
private static class CustomModTextureStatic extends ModTextureStatic {
|
private static boolean registeredOverrideTextureMap=false;
|
||||||
public CustomModTextureStatic(int i, BufferedImage bufferedimage) {
|
|
||||||
super(i, 0, bufferedimage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindImage(RenderEngine renderengine) {
|
|
||||||
GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, renderengine
|
|
||||||
.getTexture(BuildCraftCore.externalBuildCraftTexture));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// FIXING GENERAL MLMP AND DEOBFUSCATION DERPINESS
|
/// FIXING GENERAL MLMP AND DEOBFUSCATION DERPINESS
|
||||||
public static void addName(Object obj, String s) {
|
public static void addName(Object obj, String s) {
|
||||||
ModLoader.addName(obj, s);
|
ModLoader.addName(obj, s);
|
||||||
|
@ -96,45 +88,19 @@ public class CoreProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Change this one to the first empty row, at the moment it is row 8
|
|
||||||
private static int textureStartingIndex = 0; //10 * 16;
|
|
||||||
// The current free index
|
|
||||||
private static int textureIndex = textureStartingIndex;
|
|
||||||
// This is calculated by the amount of open slots until there is another
|
|
||||||
// block on the sheet. Starting at row 8 you have 3 empty rows of 16 + 13
|
|
||||||
// empty in the next row
|
|
||||||
private static int textureStopIndex = 15 + 15*16 - 1;//textureStartingIndex + 61;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an override to the buildcraft texture file, mainly to provide
|
* Adds an override to the buildcraft texture file, mainly to provide
|
||||||
* pipes with icons.
|
* pipes with icons.
|
||||||
*/
|
*/
|
||||||
public static int addCustomTexture(String pathToTexture) {
|
public static int addCustomTexture(String pathToTexture) {
|
||||||
// loadTextureIndex();
|
if (!registeredOverrideTextureMap) {
|
||||||
try {
|
char[] map=new char[256];
|
||||||
if (textureIndex >= textureStopIndex) {
|
// every slot is free!
|
||||||
System.out.println("Out of BuildCraft Textures!");
|
Arrays.fill(map,'1');
|
||||||
return 0;
|
SpriteHelper.registerSpriteMapForFile(BuildCraftCore.externalBuildCraftTexture, new String(map));
|
||||||
}
|
registeredOverrideTextureMap=true;
|
||||||
CustomModTextureStatic modtexturestatic;
|
|
||||||
modtexturestatic = new CustomModTextureStatic(textureIndex,
|
|
||||||
ModLoader.loadImage(
|
|
||||||
ModLoader.getMinecraftInstance().renderEngine,
|
|
||||||
pathToTexture));
|
|
||||||
ModLoader.getMinecraftInstance().renderEngine
|
|
||||||
.registerTextureFX(modtexturestatic);
|
|
||||||
System.out.println("Overriding " + BuildCraftCore.externalBuildCraftTexture + " @ "
|
|
||||||
+ textureIndex + " With " + pathToTexture + ". "
|
|
||||||
+ (textureStopIndex - textureIndex) + " left.");
|
|
||||||
int i = textureIndex;
|
|
||||||
textureIndex++;
|
|
||||||
return i + 256;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return 0; // Error, but the game won't crash, just have the wrong
|
|
||||||
// texture
|
|
||||||
}
|
}
|
||||||
|
return ModLoader.addOverride(BuildCraftCore.externalBuildCraftTexture, pathToTexture) + 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getHash (IBlockAccess iBlockAccess) {
|
public static long getHash (IBlockAccess iBlockAccess) {
|
||||||
|
|
Loading…
Reference in a new issue