本文整理匯總了Java中net.minecraft.client.renderer.RenderItem類的典型用法代碼示例。如果您正苦於以下問題:Java RenderItem類的具體用法?Java RenderItem怎麽用?Java RenderItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RenderItem類屬於net.minecraft.client.renderer包,在下文中一共展示了RenderItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderItemInWorld
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
public static void renderItemInWorld(ItemStack stack){
if(!stack.isEmpty()){
Minecraft mc = Minecraft.getMinecraft();
RenderItem renderer = mc.getRenderItem();
TextureManager manager = mc.getTextureManager();
IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null);
manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.pushMatrix();
model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false);
renderer.renderItem(stack, model);
GlStateManager.cullFace(GlStateManager.CullFace.BACK);
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
}
示例2: renderAffinity
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
private void renderAffinity(ItemStack affinity) {
RenderItem itemRenderer = minecraft.getRenderItem();
if (affinity != null) {
double local = (period * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
float hoverHeight = (float) ((0.4 * (Math.sin(local))) / 8);
GlStateManager.translate(0.5F, 1.2F + hoverHeight, 0.5F);
EntityItem entityItem = new EntityItem(getWorld(), 0, 0, 0, affinity);
entityItem.getEntityItem().stackSize = 1;
entityItem.hoverStart = 0.0F;
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.pushAttrib();
RenderHelper.enableStandardItemLighting();
itemRenderer.renderItem(entityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);
RenderHelper.disableStandardItemLighting();
GlStateManager.popAttrib();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
GlStateManager.translate(0.0F, -hoverHeight, 0.0F);
}
}
示例3: drawDisabledSlot
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
/**
* Draws a slot that is disabled...
*
* @param x slot x
* @param y slot y
* @param renderItem Item Render
*/
public static void drawDisabledSlot(int x, int y, RenderItem renderItem) {
new GuiUtils().zLevel = 100.f;
renderItem.zLevel = 100.0f;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int colorOverlay = new Color(139, 139, 139, 200).hashCode();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
renderItem.renderItemAndEffectIntoGUI(new ItemStack(Blocks.AIR), x, y);
new GuiUtils().drawGradientRect(x, y, x + 16, y + 16, colorOverlay, colorOverlay);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
new GuiUtils().zLevel = 0.0f;
renderItem.zLevel = 0.0f;
}
示例4: renderSaiLeft
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
private void renderSaiLeft(int id) {
RenderItem renderer = Minecraft.getMinecraft().getRenderItem();
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, -0.1);
GlStateManager.translate(0, 0.625, 0);
GlStateManager.rotate(180, 1, 0, 0);
GlStateManager.translate(0.275, 0, 0);
GlStateManager.rotate(-90, 0, 1, 0);
GlStateManager.scale(0.5, 0.5, 1);
renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
示例5: renderSaiRight
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
private void renderSaiRight(int id) {
RenderItem renderer = Minecraft.getMinecraft().getRenderItem();
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, -0.1);
GlStateManager.translate(0, 0.625, 0);
GlStateManager.rotate(180, 1, 0, 0);
GlStateManager.translate(-0.275, 0, 0);
GlStateManager.rotate(-90, 0, 1, 0);
GlStateManager.scale(0.5, 0.5, 1);
renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
示例6: renderRopeCoil
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
private void renderRopeCoil(int id) {
RenderItem renderer = Minecraft.getMinecraft().getRenderItem();
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, -0.15);
GlStateManager.translate(0, 1.25, 0);
GlStateManager.rotate(180, 1, 0, 0);
GlStateManager.translate(0.3, 0, 0);
GlStateManager.rotate(-90, 0, 1, 0);
GlStateManager.rotate(-90, 0, 0, 1);
GlStateManager.scale(0.8, 0.8, 1);
renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
示例7: sanitizeEntityRenderers
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
@SideOnly (Side.CLIENT)
public static void sanitizeEntityRenderers(RenderManager renderManager) {
if (!hasSanitized) {
try {
for (Render<? extends Entity> render : renderManager.entityRenderMap.values()) {
if (render != null) {
for (Field field : render.getClass().getDeclaredFields()) {
if (field.getType().equals(RenderItem.class)) {
field.setAccessible(true);
field.set(render, CCRenderItem.getOverridenRenderItem());
}
}
}
}
} catch (Exception e) {
throw new RuntimeException("Unable to reflect an EntityRenderer!", e);
}
hasSanitized = true;
}
}
示例8: renderTileEntityAt
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
@Override
public void renderTileEntityAt(TileMetal te, double x, double y, double z, float partialTicks, int destroyStage)
{
RenderItem renderer = Minecraft.getMinecraft().getRenderItem();
GlStateManager.pushMatrix();
GlStateManager.translate(x+0.5D,y+0.05D,z+0.5D);
EntityItem stack = new EntityItem(getWorld(),0,0,0,te.blankStack);
stack.getEntityItem().stackSize = 1;
stack.hoverStart = 0.0F;
GlStateManager.disableLighting();
GlStateManager.rotate(-90,1,0,0);
GlStateManager.scale(0.5D,0.5D,0.5D);
GlStateManager.pushAttrib();
RenderHelper.disableStandardItemLighting();
renderer.renderItem(stack.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);
RenderHelper.enableStandardItemLighting();
GlStateManager.popAttrib();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
}
示例9: init
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
public static void init() {
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
for (Map.Entry<String, Block> ent : renderMap.entrySet()) {
renderItem.getItemModelMesher().register(Item.getItemFromBlock(ent.getValue()), 0, new ModelResourceLocation(Reference.MODID + ":" + ent.getKey(), "inventory"));
}
//TODO Convert to Lambda
for (Map.Entry<Material, Block> entry : oreBlockMap.entrySet()) {
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return entry.getKey().getColour().getRGB();
}
}, entry.getValue());
}
}
示例10: drawItemStack
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
/**
* Draws an ItemStack
*
* @param itemStack itemstack to draw
* @param x startX
* @param y startY
*/
public void drawItemStack(ItemStack itemStack, int x, int y) {
int[][] savedGLState = OpenGLHelper.saveGLState(new int[]{GL11.GL_ALPHA_TEST, GL11.GL_LIGHTING});
RenderItem renderItem = mc.getRenderItem();
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
renderItem.renderItemIntoGUI(itemStack, x, y);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
OpenGLHelper.restoreGLState(savedGLState);
}
示例11: drawDisabledSlot
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
/**
* Draws a slot that is disabled...
*
* @param x slot x
* @param y slot y
* @param renderItem Item Render
*/
public void drawDisabledSlot(int x, int y, RenderItem renderItem) {
this.zLevel = 100.f;
renderItem.zLevel = 100.0f;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int colorOverlay = new Color(139, 139, 139, 200).hashCode();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
renderItem.renderItemAndEffectIntoGUI(new ItemStack(Blocks.BARRIER), x, y);
this.drawGradientRect(x, y, x + 16, y + 16, colorOverlay, colorOverlay);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.zLevel = 0.0f;
renderItem.zLevel = 0.0f;
}
示例12: renderItemOnBlock
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
private void renderItemOnBlock(World world, ItemStack itemStack)
{
RenderItem itemRenderer = minecraft.getRenderItem();
if (itemStack != null && !(itemStack.getItem() instanceof ItemBlock))
{
GlStateManager.translate(0.0F, -0.98F, 0.0F);
EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemStack);
entityitem.getEntityItem().stackSize = 1;
entityitem.hoverStart = 0.0F;
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
GlStateManager.rotate(180, 0.0F, 1.0F, 1.0F);
GlStateManager.scale(0.75F, 0.75F, 0.75F);
GlStateManager.pushAttrib();
RenderHelper.enableStandardItemLighting();
itemRenderer.renderItem(entityitem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);
RenderHelper.disableStandardItemLighting();
GlStateManager.popAttrib();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
}
}
示例13: renderObject
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
public static boolean renderObject(Minecraft mc, RenderItem itemRender, int x, int y, Object itm, boolean highlight, float lvl) {
itemRender.zLevel = lvl;
if (itm==null) {
return renderItemStack(mc, itemRender, null, x, y, "", highlight);
}
if (itm instanceof Item) {
return renderItemStack(mc, itemRender, new ItemStack((Item) itm, 1), x, y, "", highlight);
}
if (itm instanceof Block) {
return renderItemStack(mc, itemRender, new ItemStack((Block) itm, 1), x, y, "", highlight);
}
if (itm instanceof ItemStack) {
return renderItemStackWithCount(mc, itemRender, (ItemStack) itm, x, y, highlight);
}
// if (itm instanceof IIcon) {
// return renderIcon(mc, itemRender, (IIcon) itm, x, y, highlight);
// }
return renderItemStack(mc, itemRender, null, x, y, "", highlight);
}
示例14: render
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
@SuppressWarnings("unused")
private void render(Object block) {
if (block instanceof Block && block instanceof ICustomBlock) {
if (Sponge.getPlatform().getExecutionType().isClient()) {
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
renderItem.getItemModelMesher().register(
Item.getItemFromBlock((Block) block),
0,
new ModelResourceLocation(
"skree:" + ((ICustomBlock) block).__getID(),
"inventory"
)
);
}
} else {
throw new IllegalArgumentException("Invalid custom item!");
}
}
示例15: drawItem
import net.minecraft.client.renderer.RenderItem; //導入依賴的package包/類
@Override
protected void drawItem(TexturePallette item, Minecraft mc, RenderItem itemRender, double left, double top, float partialTicks, boolean isHighlighted)
{
int size = this.actualItemPixels();
// if texture is translucent provide a background
if(this.renderAlpha) GuiUtil.drawRect(left, top, left + size, top + size, this.baseColor);
Rotation rotation = item.rotation.rotationType() == TextureRotationType.RANDOM
? Rotation.values()[(int) ((CommonProxy.currentTimeMillis() >> 11) & 3)]
: item.rotation.rotation;
TextureAtlasSprite tex = mc.getTextureMapBlocks().getAtlasSprite(item.getSampleTextureName());
GuiUtil.drawTexturedRectWithColor(left, top, this.zLevel, tex, size, size, this.borderColor, item.textureScale, rotation, renderAlpha);
}