2011-07-15 23:13:09 +00:00
|
|
|
/**
|
|
|
|
* This software is provided under the terms of the Minecraft Forge Public
|
|
|
|
* License v1.0.
|
|
|
|
*/
|
|
|
|
|
2011-07-15 23:04:10 +00:00
|
|
|
package net.minecraft.src.forge;
|
|
|
|
|
|
|
|
import net.minecraft.src.Block;
|
2011-09-03 11:46:59 +00:00
|
|
|
import net.minecraft.src.Item;
|
2011-07-15 23:04:10 +00:00
|
|
|
import net.minecraft.src.ModLoader;
|
|
|
|
import net.minecraft.src.RenderBlocks;
|
|
|
|
|
|
|
|
public class MinecraftForgeClient {
|
2011-08-20 10:35:14 +00:00
|
|
|
/**
|
|
|
|
* Registers a new block highlight handler.
|
|
|
|
*/
|
|
|
|
public static void registerHighlightHandler(IHighlightHandler handler) {
|
|
|
|
ForgeHooksClient.highlightHandlers.add(handler);
|
|
|
|
}
|
|
|
|
|
2011-12-21 09:01:45 +00:00
|
|
|
/** Register a new render context handler. A render context is a block
|
|
|
|
* of rendering performed with similar OpenGL modes, for example,
|
|
|
|
* texture name.
|
|
|
|
* @param tex The name of the texture for this render context.
|
|
|
|
* @param sub The subid of this render context. 0 is the default pass
|
|
|
|
* for normal rendering, higher subids render later. All subids of 0
|
|
|
|
* will render before all subids of 1, etc.
|
|
|
|
* @param handler The handler to register.
|
|
|
|
*/
|
|
|
|
public static void registerRenderContextHandler(String tex, int sub,
|
|
|
|
IRenderContextHandler handler) {
|
|
|
|
ForgeHooksClient.registerRenderContextHandler(tex,sub,handler);
|
|
|
|
}
|
|
|
|
|
2011-08-12 23:53:30 +00:00
|
|
|
/** Bind a texture. This is used to bind a texture file when
|
|
|
|
* performing your own rendering, rather than using ITextureProvider.
|
|
|
|
*
|
|
|
|
* This variation is reserved for future expansion.
|
|
|
|
*/
|
2011-08-05 11:07:03 +00:00
|
|
|
public static void bindTexture(String name, int sub) {
|
|
|
|
ForgeHooksClient.bindTexture(name,sub);
|
|
|
|
}
|
2011-07-15 23:04:10 +00:00
|
|
|
|
2011-08-12 23:53:30 +00:00
|
|
|
/** Bind a texture. This is used to bind a texture file when
|
|
|
|
* performing your own rendering, rather than using ITextureProvider.
|
|
|
|
*/
|
2011-08-05 11:07:03 +00:00
|
|
|
public static void bindTexture(String name) {
|
|
|
|
ForgeHooksClient.bindTexture(name,0);
|
|
|
|
}
|
2011-07-15 23:04:10 +00:00
|
|
|
|
2011-08-12 23:53:30 +00:00
|
|
|
/** Unbind a texture. This binds the default texture, when you are
|
|
|
|
* finished performing custom rendering.
|
|
|
|
*/
|
2011-08-05 11:07:03 +00:00
|
|
|
public static void unbindTexture() {
|
|
|
|
ForgeHooksClient.unbindTexture();
|
|
|
|
}
|
2011-08-05 11:58:14 +00:00
|
|
|
|
2011-08-12 23:53:30 +00:00
|
|
|
/** Preload a texture. Textures must be preloaded before the first
|
|
|
|
* use, or they will cause visual anomalies.
|
|
|
|
*/
|
2011-08-05 11:58:14 +00:00
|
|
|
public static void preloadTexture(String texture) {
|
|
|
|
ModLoader.getMinecraftInstance().renderEngine
|
|
|
|
.getTexture(texture);
|
|
|
|
}
|
2011-08-12 23:53:30 +00:00
|
|
|
|
|
|
|
/** Render a block. Render a block which may have a custom texture.
|
|
|
|
*/
|
|
|
|
public static void renderBlock(RenderBlocks rb, Block bl, int i, int
|
|
|
|
j, int k) {
|
|
|
|
ForgeHooksClient.beforeBlockRender(bl,rb);
|
|
|
|
rb.renderBlockByRenderType(bl,i,j,k);
|
|
|
|
ForgeHooksClient.afterBlockRender(bl,rb);
|
|
|
|
}
|
2011-08-17 10:23:10 +00:00
|
|
|
|
|
|
|
/** Get the current render pass.
|
|
|
|
*/
|
|
|
|
public static int getRenderPass() {
|
|
|
|
return ForgeHooksClient.renderPass;
|
|
|
|
}
|
2011-09-03 11:46:59 +00:00
|
|
|
|
|
|
|
private static ICustomItemRenderer [] customItemRenderers = new ICustomItemRenderer [Item.itemsList.length];
|
|
|
|
|
|
|
|
public static void registerCustomItemRenderer (int itemID, ICustomItemRenderer renderer) {
|
|
|
|
customItemRenderers [itemID] = renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ICustomItemRenderer getCustomItemRenderer (int itemID) {
|
|
|
|
return customItemRenderers [itemID];
|
|
|
|
}
|
2012-02-10 11:06:08 +00:00
|
|
|
|
|
|
|
private static boolean hasInit = false;
|
|
|
|
public static void init()
|
|
|
|
{
|
|
|
|
if (hasInit)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hasInit = true;
|
|
|
|
ForgeHooks.setPacketHandler(new PacketHandlerClient());
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
2011-07-15 23:04:10 +00:00
|
|
|
}
|