mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 15:33:18 +00:00
More patches converted.
Refactored some of the events to be a better hiarachy.
This commit is contained in:
1 parent
80ad4be5b1
commit
31a908b754
55 files changed
+1616
-584
No files matched your search
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* This software is provided under the terms of the Minecraft Forge Public
|
||||
* License v1.0.
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.ModLoader;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
|
||||
public class MinecraftForgeClient
|
||||
{
|
||||
/** Register a new render context handler. A render context is a block
|
||||
* of rendering performed with similar OpenGL modes, for example,
|
||||
* texture name.
|
||||
* @param texture The name of the texture for this render context.
|
||||
* @param subid 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 texture, int subid, IRenderContextHandler handler)
|
||||
{
|
||||
ForgeHooksClient.registerRenderContextHandler(texture, subid, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload a texture. Textures must be preloaded before the first
|
||||
* use, or they will cause visual anomalies.
|
||||
*/
|
||||
public static void preloadTexture(String texture)
|
||||
{
|
||||
ModLoader.getMinecraftInstance().renderEngine.getTexture(texture);
|
||||
}
|
||||
|
||||
/** Render a block. Render a block which may have a custom texture.
|
||||
*/
|
||||
public static void renderBlock(RenderBlocks render, Block block, int x, int y, int z)
|
||||
{
|
||||
ForgeHooksClient.beforeBlockRender(block, render);
|
||||
render.renderBlockByRenderType(block, x, y, z);
|
||||
ForgeHooksClient.afterBlockRender(block, render);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current render pass.
|
||||
*/
|
||||
public static int getRenderPass()
|
||||
{
|
||||
return ForgeHooksClient.renderPass;
|
||||
}
|
||||
|
||||
private static IItemRenderer[] customItemRenderers = new IItemRenderer[Item.itemsList.length];
|
||||
|
||||
/**
|
||||
* Register a custom renderer for a specific item. This can be used to
|
||||
* render the item in-world as an EntityItem, when the item is equipped, or
|
||||
* when the item is in an inventory slot.
|
||||
* @param itemID The item ID (shifted index) to handle rendering.
|
||||
* @param renderer The IItemRenderer interface that handles rendering for
|
||||
* this item.
|
||||
*/
|
||||
public static void registerItemRenderer(int itemID, IItemRenderer renderer)
|
||||
{
|
||||
customItemRenderers[itemID] = renderer;
|
||||
}
|
||||
|
||||
public static IItemRenderer getItemRenderer(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
IItemRenderer renderer = customItemRenderers[item.itemID];
|
||||
if (renderer != null && renderer.handleRenderType(item, type))
|
||||
{
|
||||
return customItemRenderers[item.itemID];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean hasInit = false;
|
||||
public static void init()
|
||||
{
|
||||
if (hasInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hasInit = true;
|
||||
ForgeHooks.setPacketHandler(new PacketHandlerClient());
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
/***
|
||||
* This is a function that is used to enforce deprecation of code.
|
||||
* It checks the current Display's title against the passed in argument.
|
||||
* If they do not match (such is the case in different versionf of MC) it exits the process with a error
|
||||
*
|
||||
* @param version The version to find, usually "Minecraft Minecraft 1.2.3"
|
||||
* @param message The error message to display in the crash log
|
||||
*/
|
||||
public static void checkMinecraftVersion(String version, String message)
|
||||
{
|
||||
if (!Display.getTitle().equals(version))
|
||||
{
|
||||
MinecraftForge.killMinecraft("Minecraft Forge", message.replaceAll("%version%", Display.getTitle()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user