net.minecraft.client.Minecraft.getRenderItem()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(12.8k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中net.minecraft.client.Minecraft.getRenderItem()方法的一些代码示例,展示了Minecraft.getRenderItem()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Minecraft.getRenderItem()方法的具体详情如下:
包路径:net.minecraft.client.Minecraft
类名称:Minecraft
方法名:getRenderItem

Minecraft.getRenderItem介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public RenderFloatingItem( final RenderManager manager )
{
  super( manager, Minecraft.getMinecraft().getRenderItem() );
  this.shadowOpaque = 0.0F;
}

代码示例来源:origin: Vazkii/Botania

private void renderItem(ItemStack stack) {
  Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.HEAD);
}

代码示例来源:origin: Vazkii/Botania

@Nonnull
  @Override
  public IBakedModel handleItemState(@Nonnull IBakedModel original, ItemStack stack, World world, EntityLivingBase living) {
    IBakedModel model = bakedItemModels.get(ItemBlockSpecialFlower.getType(stack));
    if(model == null)
      model = bakedBlockModels.get(ItemBlockSpecialFlower.getType(stack));
    if(model == null)
      model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(roseFallback);
    return model;
  }
};

代码示例来源:origin: Vazkii/Botania

@Nonnull
  @Override
  public IBakedModel handleItemState(@Nonnull IBakedModel model, ItemStack stack, World world, EntityLivingBase entity) {
    ItemStack lens = ItemManaGun.getLens(stack);
    if(!lens.isEmpty()) {
      IBakedModel lensModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(lens);
      return GunModel.this.getModel(lensModel);
    }
    else return GunModel.this;
  }
};

代码示例来源:origin: Vazkii/Botania

@Override
public void drawButton(@Nonnull Minecraft par1Minecraft, int par2, int par3, float partialTicks) {
  hovered = par2 >= x && par3 >= y && par2 < x + width && par3 < y + height;
  int k = getHoverState(hovered);
  par1Minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  GlStateManager.color(1F, 1F, 1F, 1F);
  par1Minecraft.getRenderItem().renderItemIntoGUI(new ItemStack(ModItems.cacophonium), x, y);
  par1Minecraft.getRenderItem().renderItemIntoGUI(new ItemStack(Items.FIREWORKS), x + 8, y + 2);
  GlStateManager.disableLighting();
  List<String> tooltip = new ArrayList<>();
  tooltip.add(TextFormatting.LIGHT_PURPLE + "Happy Birthday Vazkii!");
  tooltip.add(TextFormatting.GRAY + "doot doot");
  if(k == 2)
    RenderHelper.renderTooltip(x - 100, y + 36, tooltip);
  GlStateManager.enableAlpha();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public void renderTileEntityAt( T te, double x, double y, double z, float partialTicks, int destroyStage )
{
  Pair<ItemStack, Matrix4f> pair = this.f.apply( te );
  if( pair != null && pair.getLeft() != null )
  {
    GlStateManager.pushMatrix();
    if( pair.getRight() != null )
    {
      FloatBuffer matrix = BufferUtils.createFloatBuffer( 16 );
      pair.getRight().store( matrix );
      matrix.flip();
      GlStateManager.multMatrix( matrix );
    }
    Minecraft.getMinecraft().getRenderItem().renderItem( pair.getLeft(), TransformType.GROUND );
    GlStateManager.popMatrix();
  }
}

代码示例来源:origin: Vazkii/Botania

public void renderItem() {
  GlStateManager.pushMatrix();
  Minecraft.getMinecraft().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.NONE);
  GlStateManager.popMatrix();
}

代码示例来源:origin: Vazkii/Botania

@SideOnly(Side.CLIENT)
public void renderHUD(Minecraft mc, ScaledResolution res) {
  int x = res.getScaledWidth() / 2 + 10;
  int y = res.getScaledHeight() / 2 - 8;
  mc.getRenderItem().renderItemAndEffectIntoGUI(new ItemStack(Blocks.REDSTONE_TORCH), x, y);
  mc.fontRenderer.drawStringWithShadow(I18n.translateToLocal("botania.animatedTorch." + torchMode.name().toLowerCase()), x + 18, y + 6, 0xFF4444);
}

代码示例来源:origin: Vazkii/Botania

@Override
public void render(@Nonnull TilePrism prism, double x, double y, double z, float partTicks, int digProgress, float unused) {
  GlStateManager.pushMatrix();
  GlStateManager.translate(x, y, z);
  float pos = (float) Math.sin((ClientTickHandler.ticksInGame + partTicks) * 0.05F) * 0.5F * (1F - 1F / 16F) - 0.5F;
  ItemStack stack = prism.getItemHandler().getStackInSlot(0);
  if(!stack.isEmpty()) {
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    if(stack.getItem() instanceof ILens) {
      GlStateManager.pushMatrix();
      GlStateManager.rotate(90F, 1F, 0F, 0F);
      GlStateManager.translate(0.5F, 0.5F, pos);
      Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
      GlStateManager.popMatrix();
    }
  }
  GlStateManager.popMatrix();
}

代码示例来源:origin: Vazkii/Botania

public void renderItemStack(ItemStack stack) {
  if(!stack.isEmpty()) {
    Minecraft mc = Minecraft.getMinecraft();
    GlStateManager.pushMatrix();
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    float s = 0.25F;
    GlStateManager.scale(s, s, s);
    mc.getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
    GlStateManager.scale(1F / s, 1F / s, 1F / s);
    GlStateManager.popMatrix();
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
  }
}

代码示例来源:origin: Vazkii/Botania

@Override
@SideOnly(Side.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
  if (type == RenderType.HEAD) {
    GlStateManager.pushMatrix();
    Helper.translateToHeadLevel(player);
    Helper.translateToFace();
    Helper.defaultTransforms();
    GlStateManager.rotate(-90F, 0F, 1F, 0F);
    GlStateManager.translate(0.5F, 0.2F, 0.45F);
    Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
    GlStateManager.popMatrix();
  }
}

代码示例来源:origin: Vazkii/Botania

@Override
@SideOnly(Side.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
  if(type == RenderType.HEAD) {
    Helper.translateToHeadLevel(player);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.scale(0.8, 0.8, 0.8);
    GlStateManager.rotate(-90, 0, 1, 0);
    GlStateManager.rotate(180, 1, 0, 0);
    GlStateManager.translate(0.1625, -1.625, 0.40);
    Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this, 1), ItemCameraTransforms.TransformType.GROUND);
  }
}

代码示例来源:origin: Vazkii/Botania

private static void renderNearIndexDisplay(ScaledResolution res) {
  Minecraft mc = Minecraft.getMinecraft();
  String txt0 = I18n.format("botaniamisc.nearIndex0");
  String txt1 = TextFormatting.GRAY + I18n.format("botaniamisc.nearIndex1");
  String txt2 = TextFormatting.GRAY + I18n.format("botaniamisc.nearIndex2");
  int l = Math.max(mc.fontRenderer.getStringWidth(txt0), Math.max(mc.fontRenderer.getStringWidth(txt1), mc.fontRenderer.getStringWidth(txt2))) + 20;
  int x = res.getScaledWidth() - l - 20;
  int y = res.getScaledHeight() - 60;
  Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x44000000);
  Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x44000000);
  net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.enableRescaleNormal();
  mc.getRenderItem().renderItemAndEffectIntoGUI(new ItemStack(ModBlocks.corporeaIndex), x, y + 10);
  net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
  mc.fontRenderer.drawStringWithShadow(txt0, x + 20, y, 0xFFFFFF);
  mc.fontRenderer.drawStringWithShadow(txt1, x + 20, y + 14, 0xFFFFFF);
  mc.fontRenderer.drawStringWithShadow(txt2, x + 20, y + 24, 0xFFFFFF);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private void renderItem( final ItemStack stack, final float o, final AEBaseTile tile, final double x, final double y, final double z )
{
  if( !stack.isEmpty() )
  {
    final ItemStack sis = stack.copy();
    GlStateManager.pushMatrix();
    // move to center
    GlStateManager.translate( 0.5f, 0.5f + o, 0.5f );
    GlStateManager.rotate( 90, 1, 0, 0 );
    // set scale
    GlStateManager.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE );
    // heuristic to scale items down much further than blocks
    if( !( sis.getItem() instanceof ItemBlock ) )
    {
      GlStateManager.scale( 0.5, 0.5, 0.5 );
    }
    Minecraft.getMinecraft().getRenderItem().renderItem( sis, ItemCameraTransforms.TransformType.FIXED );
    GlStateManager.popMatrix();
  }
}

代码示例来源:origin: Vazkii/Botania

@SuppressWarnings("deprecation")
private static void renderFlower(EntityPlayer player, ItemStack flower) {
  GlStateManager.pushMatrix();
  Helper.translateToHeadLevel(player);
  Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  GlStateManager.rotate(180, 0, 0, 1);
  GlStateManager.translate(0, -0.85, 0);
  GlStateManager.rotate(-90, 0, 1, 0);
  GlStateManager.scale(0.5, 0.5, 0.5);
  ShaderHelper.useShader(ShaderHelper.gold);
  Minecraft.getMinecraft().getRenderItem().renderItem(flower, player, ItemCameraTransforms.TransformType.NONE, false);
  ShaderHelper.releaseShader();
  GlStateManager.popMatrix();
}

代码示例来源:origin: Vazkii/Botania

@Override
@SideOnly(Side.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
  if(type == RenderType.HEAD) {
    boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    Helper.translateToHeadLevel(player);
    Helper.translateToFace();
    Helper.defaultTransforms();
    GlStateManager.rotate(180F, 0F, 1F, 0F);
    GlStateManager.scale(0.5F, 0.5F, 0.5F);
    GlStateManager.translate(0.5F, -0.2F, armor ? 0.12F : 0F);
    Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
  public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity )
  {
    boolean shiftHeld = Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT );
    if( shiftHeld )
    {
      ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
      ItemStack output = iep.getOutput( stack );
      if( !output.isEmpty() )
      {
        IBakedModel realModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel( output );
        // Give the item model a chance to handle the overrides as well
        realModel = realModel.getOverrides().handleItemState( realModel, output, world, entity );
        return new ShiftHoldingModelWrapper( realModel );
      }
    }
    return ItemEncodedPatternBakedModel.this.baseModel.getOverrides().handleItemState( originalModel, stack, world, entity );
  }
}

代码示例来源:origin: Vazkii/Botania

public static void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound) {
  drawSimpleManaHUD(color, mana, maxMana, name, res);
  Minecraft mc = Minecraft.getMinecraft();
  int x = res.getScaledWidth() / 2 + 55;
  int y = res.getScaledHeight() / 2 + 12;
  net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.enableRescaleNormal();
  mc.getRenderItem().renderItemAndEffectIntoGUI(bindDisplay, x, y);
  net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
  GlStateManager.disableDepth();
  if(properlyBound) {
    mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 9, 0x004C00);
    mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 8, 0x0BD20D);
  } else {
    mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 9, 0x4C0000);
    mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 8, 0xD2080D);
  }
  GlStateManager.enableDepth();
}

代码示例来源:origin: Vazkii/Botania

@Override
public void drawScreenAfterScale(int xCoord, int yCoord, float newPartialTicks) {
  super.drawScreenAfterScale(xCoord, yCoord, newPartialTicks);
  RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.enableRescaleNormal();
  mc.getRenderItem().renderItemIntoGUI(challenge.icon, left + 18, top + 15);
  RenderHelper.disableStandardItemLighting();
  GlStateManager.enableBlend();
  boolean unicode = fontRenderer.getUnicodeFlag();
  fontRenderer.setUnicodeFlag(true);
  fontRenderer.drawString(TextFormatting.BOLD + I18n.format(challenge.unlocalizedName), left + 38, top + 13, 0);
  fontRenderer.drawString(I18n.format(challenge.level.getName()) + ((challenge.icon.getItem() == ModItems.rune) ? "+" : "") + " / " + (challenge.complete ? TextFormatting.DARK_GREEN : TextFormatting.DARK_RED) + I18n.format(challenge.complete ? "botaniamisc.completed" : "botaniamisc.notCompleted"), left + 38, top + 23, 0);
  int width = guiWidth - 30;
  int x = left + 16;
  int y = top + 28;
  PageText.renderText(x, y, width, guiHeight, challenge.unlocalizedName + ".desc");
  fontRenderer.setUnicodeFlag(unicode);
}

代码示例来源:origin: Vazkii/Botania

public void renderKamuiBlack() {
  // Modified copy of RenderItem.renderItem(stack, transformtype)
  Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
  IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(renderStack);
  GlStateManager.enableRescaleNormal();
  GlStateManager.alphaFunc(516, 0.1F);
  GlStateManager.enableBlend();
  GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  GlStateManager.pushMatrix();
  model = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.NONE, false);
  renderModel(model, renderStack, 0xFF00004C);
  GlStateManager.cullFace(GlStateManager.CullFace.BACK);
  GlStateManager.popMatrix();
  GlStateManager.disableRescaleNormal();
  GlStateManager.disableBlend();
  Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}

相关文章