Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In the client proxy, put these methods
- // Some of the indenting is messed up, sorry :(
- // Put a dummy method for this in CommonProxy as well
- @Override
- public int getTexture( String path )
- {
- Integer i = textures.get( path );
- return ( i == null ? 0 : i );
- }
- // You can probably take the Icon stuff out, it was for my purposes
- private void makeTextureFor( String str, Icon icon )
- {
- System.out.println( "Generating texture " + str + "..." );
- try
- {
- Minecraft mc = FMLClientHandler.instance().getClient();
- RenderEngine re = mc.renderEngine;
- String texPath = iconToPath( re, icon );
- ITexturePack pack = mc.texturePackList.getSelectedTexturePack();
- BufferedImage other = ImageIO.read( pack.getResourceAsStream( texPath ) );
- BufferedImage image = new BufferedImage( 64, 32, BufferedImage.TYPE_INT_ARGB );
- // Generate image here
- int id = re.allocateAndSetupTexture( image );
- textures.put( str, id );
- }
- catch ( Exception exception )
- {
- exception.printStackTrace();
- }
- }
- private String iconToPath( RenderEngine re, Icon icon )
- {
- final String basePath = re.textureMapBlocks.basePath;
- final String textureExt = re.textureMapBlocks.textureExt;
- String name = icon.getIconName();
- String path;
- if (name.indexOf(':') == -1)
- {
- path = basePath + name + textureExt;
- }
- else
- {
- String domain = name.substring(0, name.indexOf(':'));
- String file = name.substring(name.indexOf(':') + 1);
- path = "mods/" + domain +"/" + basePath + file + textureExt;
- }
- return "/" + path;
- }
- private Map< String, Integer > textures;
- // Binding the texture is something like this:
- String path = "/mod/someMod/texture/mytexture.png";
- GL11.glBindTexture( GL11.GL_TEXTURE_2D, MOD.instance.proxy.getTexture( path ) );
- // And make SURE to do this:
- tileEntityRenderer.renderEngine.resetBoundTexture();
- // Otherwise you get something like this: http://spacechase0.com/wp-content/uploads/2013/04/1365528599_21425.png
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement