2011-07-15 23:13:09 +00:00
|
|
|
/**
|
2012-02-25 06:07:58 +00:00
|
|
|
* This software is provided under the terms of the Minecraft Forge Public
|
2011-07-15 23:13:09 +00:00
|
|
|
* License v1.0.
|
|
|
|
*/
|
|
|
|
|
2012-08-06 22:07:53 +00:00
|
|
|
package net.minecraftforge.client;
|
2011-07-15 23:04:10 +00:00
|
|
|
|
2013-05-16 00:29:47 +00:00
|
|
|
import java.util.BitSet;
|
2013-12-21 08:10:35 +00:00
|
|
|
import java.util.IdentityHashMap;
|
2013-05-16 00:29:47 +00:00
|
|
|
|
2013-12-21 08:10:35 +00:00
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2012-08-06 22:07:53 +00:00
|
|
|
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
2011-07-15 23:04:10 +00:00
|
|
|
|
2012-02-25 06:07:58 +00:00
|
|
|
public class MinecraftForgeClient
|
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
private static IdentityHashMap<Item, IItemRenderer> customItemRenderers = Maps.newIdentityHashMap();
|
2012-03-17 18:46:15 +00:00
|
|
|
|
2012-09-09 14:02:21 +00:00
|
|
|
/**
|
2012-08-06 22:07:53 +00:00
|
|
|
* Register a custom renderer for a specific item. This can be used to
|
2012-03-17 18:46:15 +00:00
|
|
|
* 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.
|
2012-03-16 04:26:09 +00:00
|
|
|
*/
|
2013-12-21 08:10:35 +00:00
|
|
|
public static void registerItemRenderer(Item item, IItemRenderer renderer)
|
2012-03-16 04:26:09 +00:00
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
customItemRenderers.put(item, renderer);
|
2012-03-16 04:26:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-19 18:37:51 +00:00
|
|
|
public static IItemRenderer getItemRenderer(ItemStack item, ItemRenderType type)
|
2012-03-16 04:26:09 +00:00
|
|
|
{
|
2014-01-06 04:55:04 +00:00
|
|
|
IItemRenderer renderer = customItemRenderers.get(item.getItem());
|
2012-09-09 14:02:21 +00:00
|
|
|
if (renderer != null && renderer.handleRenderType(item, type))
|
2012-03-23 02:46:36 +00:00
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
return renderer;
|
2012-03-17 18:46:15 +00:00
|
|
|
}
|
|
|
|
return null;
|
2012-02-25 06:07:58 +00:00
|
|
|
}
|
2013-03-07 03:18:26 +00:00
|
|
|
|
2013-03-07 03:26:29 +00:00
|
|
|
public static int getRenderPass()
|
2013-03-07 03:18:26 +00:00
|
|
|
{
|
|
|
|
return ForgeHooksClient.renderPass;
|
|
|
|
}
|
2013-05-09 00:13:19 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
private static BitSet stencilBits = new BitSet(8);
|
2013-05-16 00:29:47 +00:00
|
|
|
static
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
stencilBits.set(0,8);
|
2013-05-16 00:29:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reserve a stencil bit for use in rendering
|
|
|
|
*
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
* Note: you must check the Framebuffer you are working with to
|
|
|
|
* determine if stencil bits are enabled on it before use.
|
|
|
|
*
|
2013-05-16 00:29:47 +00:00
|
|
|
* @return A bit or -1 if no further stencil bits are available
|
|
|
|
*/
|
|
|
|
public static int reserveStencilBit()
|
|
|
|
{
|
|
|
|
int bit = stencilBits.nextSetBit(0);
|
|
|
|
if (bit >= 0)
|
|
|
|
{
|
|
|
|
stencilBits.clear(bit);
|
|
|
|
}
|
|
|
|
return bit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release the stencil bit for other use
|
|
|
|
*
|
|
|
|
* @param bit The bit from {@link #reserveStencilBit()}
|
|
|
|
*/
|
|
|
|
public static void releaseStencilBit(int bit)
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (bit >= 0 && bit < stencilBits.length())
|
2013-05-16 00:29:47 +00:00
|
|
|
{
|
|
|
|
stencilBits.set(bit);
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 23:04:10 +00:00
|
|
|
}
|