Java 类net.minecraftforge.client.ForgeHooksClient 实例源码

项目:Metalworks    文件:Util.java   
@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();
    }
}
项目:Machines-and-Stuff    文件:RenderAccumulator.java   
public static void renderBlockModel(World world, BlockPos pos, IBlockState state) {
    VertexBuffer wr = Tessellator.getInstance().getBuffer();
    wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    wr.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
    IBakedModel ibakedmodel = modelShapes.getModelForState(state);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

    for(BlockRenderLayer layer : BlockRenderLayer.values()) {
        if(state.getBlock().canRenderInLayer(state, layer)) {
            ForgeHooksClient.setRenderLayer(layer);
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, ibakedmodel, state, pos, wr, true);
        }
    }
    ForgeHooksClient.setRenderLayer(null);
    wr.setTranslation(0, 0, 0);
    Tessellator.getInstance().draw();
}
项目:CrystalMod    文件:DynamicBaseModel.java   
/**
 * Add a given rotated quad to a list of quads.
 * @param quads The quads to append to.
 * @param x1 Start X
 * @param x2 End X
 * @param z1 Start Z
 * @param z2 End Z
 * @param y Y
 * @param texture The base texture
 * @param side The side to add render quad at.
 * @param rotation The rotation index to rotate by.
 * @param isColored When set to true a colored baked quad will be made, otherwise a regular baked quad is used.
 * @param shadeColor The shade color
 * @param uvs A double array of 4 uv pairs
 */
public static void addBakedQuadRotated(List<BakedQuad> quads, float x1, float x2, float z1, float z2, float y,
                                          TextureAtlasSprite texture, EnumFacing side, int rotation,
                                          boolean isColored, int shadeColor, float[][] uvs) {
    Vec3d v1 = rotate(new Vec3d(x1 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5);
    Vec3d v2 = rotate(new Vec3d(x1 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5);
    Vec3d v3 = rotate(new Vec3d(x2 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5);
    Vec3d v4 = rotate(new Vec3d(x2 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5);
    int[] data =  Ints.concat(
            vertexToInts((float) v1.xCoord, (float) v1.yCoord, (float) v1.zCoord, shadeColor, texture, uvs[(0 + rotation) % 4][0] * 16, uvs[(0 + rotation) % 4][1] * 16),
            vertexToInts((float) v2.xCoord, (float) v2.yCoord, (float) v2.zCoord, shadeColor, texture, uvs[(1 + rotation) % 4][0] * 16, uvs[(1 + rotation) % 4][1] * 16),
            vertexToInts((float) v3.xCoord, (float) v3.yCoord, (float) v3.zCoord, shadeColor, texture, uvs[(2 + rotation) % 4][0] * 16, uvs[(2 + rotation) % 4][1] * 16),
            vertexToInts((float) v4.xCoord, (float) v4.yCoord, (float) v4.zCoord, shadeColor, texture, uvs[(3 + rotation) % 4][0] * 16, uvs[(3 + rotation) % 4][1] * 16)
    );
    ForgeHooksClient.fillNormal(data, side); // This fixes lighting issues when item is rendered in hand/inventory
    quads.add(new BakedQuad(data, -1, side, texture, false, Attributes.DEFAULT_BAKED_FORMAT));
}
项目:placementpreview    文件:RenderEventHandler.java   
private void getQuads(ModelHolder holder, List<BakedQuad> quads)
{
    if (holder.actualState.getRenderType() == EnumBlockRenderType.MODEL/* ||
        holder.actualState.getRenderType() == EnumBlockRenderType.LIQUID*/)
    {
        BlockRenderLayer originalLayer = MinecraftForgeClient.getRenderLayer();

        for (BlockRenderLayer layer : BlockRenderLayer.values())
        {
            if (holder.actualState.getBlock().canRenderInLayer(holder.actualState, layer))
            {
                ForgeHooksClient.setRenderLayer(layer);

                for (final EnumFacing facing : EnumFacing.values())
                {
                    quads.addAll(holder.model.getQuads(holder.extendedState, facing, 0));
                }

                quads.addAll(holder.model.getQuads(holder.extendedState, null, 0));
            }
        }

        ForgeHooksClient.setRenderLayer(originalLayer);
    }
}
项目:Qbar    文件:RenderUtil.java   
public static final void renderMultiblock(final IBlockState state, final double x, final double y, final double z,
                                          final BlockRendererDispatcher blockRender)
{
    final Minecraft minecraft = Minecraft.getMinecraft();

    minecraft.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    ForgeHooksClient.setRenderLayer(BlockRenderLayer.CUTOUT);

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

    RenderHelper.disableStandardItemLighting();
    GlStateManager.color(1f, 1f, 1f, 1f);
    final int alpha = (int) (0.5 * 0xFF) << 24;
    GlStateManager.enableBlend();
    GlStateManager.enableTexture2D();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    RenderUtil.renderQuads(blockRender.getModelForState(state).getQuads(state, null, 0), alpha);
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
项目:JABBA    文件:TileEntityBaseRenderer.java   
protected void renderStackOnBlock(ItemStack stack, ForgeDirection side, ForgeDirection orientation, Coordinates barrelPos, float size, double posx, double posy)
{
    if (stack == null) {
        return;
    }
    int[][] savedGLState = saveGLState(new int[] { 3008, 2896 });
    GL11.glPushMatrix();

    alignRendering(side, orientation, barrelPos);
    moveRendering(size, posx, posy, -0.001D);
    if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, this.texManager, stack, true, 0.0F, 0.0F, 0.0F)) {
        this.renderItem.func_77015_a(this.renderFont, this.texManager, stack, 0, 0);
    }
    GL11.glPopMatrix();
    restoreGlState(savedGLState);
}
项目:Hard-Science    文件:ShapeMeshGenerator.java   
/**
 * Find appropriate transformation assuming base model is oriented to Y orthogonalAxis, positive.
 * This is different than the Minecraft/Forge default because I brain that way.<br><br>
 * 
 * @see #getMatrixForAxisAndRotation(net.minecraft.util.EnumFacing.Axis, boolean, Rotation) for
 * more explanation.
 */
protected static Matrix4f getMatrix4f(ModelState modelState)
{
    if(modelState.hasAxis())
    {
        if(modelState.hasAxisRotation())
        {
            return getMatrixForAxisAndRotation(modelState.getAxis(), modelState.isAxisInverted(), modelState.getAxisRotation());
        }
        else
        {
            return getMatrixForAxis(modelState.getAxis(), modelState.isAxisInverted());
        }
    }
    else if(modelState.hasAxisRotation())
    {
        return getMatrixForRotation(modelState.getAxisRotation());
    }
    else
    {
        return ForgeHooksClient.getMatrix(ModelRotation.X0_Y0);
    }
}
项目:Hard-Science    文件:ShapeMeshGenerator.java   
/**
 * See {@link #getMatrixForAxisAndRotation(net.minecraft.util.EnumFacing.Axis, boolean, Rotation)}
 */
protected static Matrix4f getMatrixForAxis(EnumFacing.Axis axis, boolean isAxisInverted)
{
    switch(axis)
    {
    case X:
        return ForgeHooksClient.getMatrix(isAxisInverted ? ModelRotation.X90_Y270 : ModelRotation.X90_Y90);

    case Y:
        return ForgeHooksClient.getMatrix(isAxisInverted ? ModelRotation.X180_Y0 : ModelRotation.X0_Y0);

    case Z:
        return ForgeHooksClient.getMatrix(isAxisInverted ? ModelRotation.X90_Y0 : ModelRotation.X270_Y0);

    default:
        return ForgeHooksClient.getMatrix(ModelRotation.X0_Y0);

    }
}
项目:Hard-Science    文件:ShapeMeshGenerator.java   
/**
 * See {@link #getMatrixForAxisAndRotation(net.minecraft.util.EnumFacing.Axis, boolean, Rotation)}
 */
protected static Matrix4f getMatrixForRotation(Rotation rotation)
{
    switch(rotation)
    {
    default:
    case ROTATE_NONE:
        return ForgeHooksClient.getMatrix(ModelRotation.X0_Y0);

    case ROTATE_90:
        return ForgeHooksClient.getMatrix(ModelRotation.X0_Y90);

    case ROTATE_180:
        return ForgeHooksClient.getMatrix(ModelRotation.X0_Y180);

    case ROTATE_270:
        return ForgeHooksClient.getMatrix(ModelRotation.X0_Y270);
    }
}
项目:Hard-Science    文件:SuperBlockTESR.java   
protected void renderBlock(SuperTileEntity te, BufferBuilder buffer)
{
    SuperBlock block = (SuperBlock) te.getBlockType();
    if(block.blockRenderMode != BlockRenderMode.TESR) return;

    if(MinecraftForgeClient.getRenderPass() == 0)
    {
        ForgeHooksClient.setRenderLayer(BlockRenderLayer.SOLID);

        // FIXME: only do this when texture demands it and use FastTESR other times
        GlStateManager.disableAlpha();
        renderBlockInner(te, block, false, buffer);
        GlStateManager.enableAlpha();
        ForgeHooksClient.setRenderLayer(null);
    }
    else if(MinecraftForgeClient.getRenderPass() == 1)
    {
        ForgeHooksClient.setRenderLayer(BlockRenderLayer.TRANSLUCENT);
        renderBlockInner(te, block, true, buffer);
        ForgeHooksClient.setRenderLayer(null);
    }
}
项目:Runes-And-Silver    文件:RenderEskimoZombie.java   
/**
 * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide.
 *
 * @param entity Entity wearing the armor
 * @param stack ItemStack for the armor
 * @param slot Slot ID that the item is in
 * @param type Subtype, can be null or "overlay"
 * @return ResourceLocation pointing at the armor's texture
 */
public static ResourceLocation getArmorResource(Entity entity, ItemStack stack, int slot, String type)
{
    ItemArmor item = (ItemArmor)stack.getItem();
    String s1 = String.format("textures/models/armor/%s_layer_%d%s.png",
            bipedArmorFilenamePrefix[item.renderIndex], (slot == 2 ? 2 : 1), type == null ? "" : String.format("_%s", type));

    s1 = ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
    ResourceLocation resourcelocation = (ResourceLocation)field_110859_k.get(s1);

    if (resourcelocation == null)
    {
        resourcelocation = new ResourceLocation(s1);
        field_110859_k.put(s1, resourcelocation);
    }

    return resourcelocation;
}
项目:ZeldaSwordSkills    文件:ModelDynamicItemBlock.java   
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
    switch (cameraTransformType) {
    case FIRST_PERSON:
        GlStateManager.scale(2.0F, 2.0F, 2.0F);
        ForgeHooksClient.handleCameraTransforms(parent, cameraTransformType);
        GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, 0.0F, -0.35F);
        break;
    case THIRD_PERSON:
        GlStateManager.scale(2.0F, 2.0F, 2.0F);
        ForgeHooksClient.handleCameraTransforms(parent, cameraTransformType);
        GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.15F, 0.25F, -0.25F);
        break;
    default:
        ForgeHooksClient.handleCameraTransforms(parent, cameraTransformType);
        break;
    }
    return Pair.of(this, null);
}
项目:RuneCraftery    文件:RenderBiped.java   
/**
 * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide.
 *
 * @param entity Entity wearing the armor
 * @param stack ItemStack for the armor
 * @param slot Slot ID that the item is in
 * @param type Subtype, can be null or "overlay"
 * @return ResourceLocation pointing at the armor's texture
 */
public static ResourceLocation getArmorResource(Entity entity, ItemStack stack, int slot, String type)
{
    ItemArmor item = (ItemArmor)stack.getItem();
    String s1 = String.format("textures/models/armor/%s_layer_%d%s.png",
            bipedArmorFilenamePrefix[item.renderIndex], (slot == 2 ? 2 : 1), type == null ? "" : String.format("_%s", type));

    s1 = ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
    ResourceLocation resourcelocation = (ResourceLocation)field_110859_k.get(s1);

    if (resourcelocation == null)
    {
        resourcelocation = new ResourceLocation(s1);
        field_110859_k.put(s1, resourcelocation);
    }

    return resourcelocation;
}
项目:carpentersblocks    文件:BlockCoverable.java   
@Override
@SideOnly(Side.CLIENT)
/**
 * Returns which pass this block be rendered on. 0 for solids and 1 for alpha.
 */
public int getRenderBlockPass()
{
    /*
     * Alpha properties of block or cover depend on this returning a value
     * of 1, so it's the default value.  However, when rendering in player
     * hand we'll encounter sorting artifacts, and thus need to enforce
     * opaque rendering, or 0.
     */

    if (ForgeHooksClient.getWorldRenderPass() < 0) {
        return 0;
    } else {
        return 1;
    }
}
项目:BetterChests    文件:ClientProxy.java   
@Override
public void init() {
    new ClientEventListener();
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBChest.class, TESRBChest.INSTANCE);
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBBarrel.class, TESRBBarrel.INSTANCE);
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBTank.class, TESRBTank.INSTANCE);
    ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(BlocksItemsBetterChests.betterchest), 0, TileEntityBChest.class);

    TickRegistry.CLIENT.addContinuousCallback(() -> {
        if (!pressed && keyBind.isPressed() && Minecraft.getMinecraft().world != null) {
            //Open bag
            int idx = InvUtil.findInInvInternal(Minecraft.getMinecraft().player.inventory, null, stack -> stack.getItem() instanceof ItemBBag);
            if (idx != -1) {
                BetterChests.instance.ph.sendPacketToPlayers(new PacketOpenBag(idx));
            }
        }
        pressed = keyBind.isPressed();
    });
    ClientRegistry.registerKeyBinding(keyBind);
}
项目:BetterNutritionMod    文件:RenderBiped.java   
/**
 * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide.
 *
 * @param entity Entity wearing the armor
 * @param stack ItemStack for the armor
 * @param slot Slot ID that the item is in
 * @param type Subtype, can be null or "overlay"
 * @return ResourceLocation pointing at the armor's texture
 */
public static ResourceLocation getArmorResource(Entity entity, ItemStack stack, int slot, String type)
{
    ItemArmor item = (ItemArmor)stack.getItem();
    String s1 = String.format("textures/models/armor/%s_layer_%d%s.png",
            bipedArmorFilenamePrefix[item.renderIndex], (slot == 2 ? 2 : 1), type == null ? "" : String.format("_%s", type));

    s1 = ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
    ResourceLocation resourcelocation = (ResourceLocation)field_110859_k.get(s1);

    if (resourcelocation == null)
    {
        resourcelocation = new ResourceLocation(s1);
        field_110859_k.put(s1, resourcelocation);
    }

    return resourcelocation;
}
项目:EnderIO    文件:SoulBinderTESR.java   
@SuppressWarnings("null")
public static void renderBlockModel(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean translateToOrigin, boolean relight) {
  VertexBuffer wr = Tessellator.getInstance().getBuffer();
  wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
  if (translateToOrigin) {
    wr.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
  }
  BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
  BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
  IBakedModel ibakedmodel = modelShapes.getModelForState(state);
  final IBlockAccess worldWrapper = relight ? new WorldWrapper(world, pos) : world;
  for (BlockRenderLayer layer : BlockRenderLayer.values()) {
    if (state.getBlock().canRenderInLayer(state, layer)) {
      ForgeHooksClient.setRenderLayer(layer);
      blockrendererdispatcher.getBlockModelRenderer().renderModel(worldWrapper, ibakedmodel, state, pos, wr, false);
    }
  }
  ForgeHooksClient.setRenderLayer(null);
  if (translateToOrigin) {
    wr.setTranslation(0, 0, 0);
  }
  Tessellator.getInstance().draw();
}
项目:EnderIO    文件:QuadCollector.java   
/**
 * Adds a baked model that is expected to behave to the quad lists for the given block layer. The block layer will be set when the model is asked for its
 * quads.
 */
public void addFriendlybakedModel(BlockRenderLayer pass, IBakedModel model, @Nullable IBlockState state, long rand) {
  if (model != null) {
    BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
    ForgeHooksClient.setRenderLayer(pass);
    List<BakedQuad> generalQuads = model.getQuads(state, null, rand);
    if (!generalQuads.isEmpty()) {
      addQuads(null, pass, generalQuads);
    }
    for (EnumFacing face : EnumFacing.values()) {
      List<BakedQuad> faceQuads = model.getQuads(state, face, rand);
      if (!faceQuads.isEmpty()) {
        addQuads(face, pass, faceQuads);
      }
    }
    ForgeHooksClient.setRenderLayer(oldRenderLayer);
  }
}
项目:GlobalXP    文件:TileEntityXPBlockRenderer.java   
@Override
public void render(TileEntityXPBlock te, double x, double y, double z, float partialTicks, int destroyStage, float alpha)
{
    if(GlobalXP.config.renderNameplate)
    {
        ITextComponent levelsText = new TextComponentString((int)te.getStoredLevels() + " (" + te.getStoredXP() + ")");

        if(te != null && te.getPos() != null && rendererDispatcher.cameraHitResult != null && rendererDispatcher.cameraHitResult.getBlockPos() != null && rendererDispatcher.cameraHitResult.getBlockPos().equals(te.getPos()))
        {
            setLightmapDisabled(true);
            drawNameplate(te, levelsText.getFormattedText(), x, y, z, 12);
            setLightmapDisabled(false);
        }
    }

    double offset = Math.sin((te.getWorld().getTotalWorldTime() + partialTicks) * GlobalXP.config.bobSpeed / 8.0D) / 10.0D;
    IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(emerald, te.getWorld(), null);

    GlStateManager.enableRescaleNormal();
    GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
    GlStateManager.enableBlend();
    RenderHelper.enableStandardItemLighting();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + 0.5D, y + 0.4D + offset, z + 0.5D);
    GlStateManager.rotate((te.getWorld().getTotalWorldTime() + partialTicks) * 4.0F * (float)GlobalXP.config.spinSpeed, 0.0F, 1.0F, 0.0F);
    model = ForgeHooksClient.handleCameraTransforms(model, TransformType.GROUND, false);
    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    Minecraft.getMinecraft().getRenderItem().renderItem(emerald, model);
    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
    GlStateManager.disableBlend();
}
项目:Meltery    文件:RenderMeltery.java   
public void renderItem(double x, double y, double z, TileMeltery meltery) {
    // calculate x/z parameters
    double x1 = meltery.getPos().getX();
    double y1 = meltery.getPos().getY();
    double z1 = meltery.getPos().getZ();

    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderUtil.pre(x, y, z);
    GlStateManager.translate(0.5,1/16d,0.5);
    GlStateManager.disableCull();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    RenderHelper.enableStandardItemLighting();

    int brightness = meltery.getWorld().getCombinedLight(meltery.getPos(), 0);

    ItemStack stack = meltery.inventory.getStackInSlot(0);
    boolean isItem = !(stack.getItem() instanceof ItemBlock);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) (brightness % 0x10000) / 1f,
            (float) (brightness / 0x10000) / 1f);
    if (isItem) {
        GlStateManager.rotate(-90, 1, 0, 0);
    } else {
        GlStateManager.scale(0.5,0.5,0.5);
    }
    IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, meltery.getWorld(), null);
    model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.NONE, false);
    Minecraft.getMinecraft().getRenderItem().renderItem(stack, model);
    if (isItem) {
        GlStateManager.rotate(90, 1, 0, 0);
    }
    RenderHelper.enableStandardItemLighting();
    GlStateManager.enableCull();
    RenderUtil.post();
}
项目:FFS    文件:OverlayRenderHandler.java   
private void drawAll(BlockPos playerPos, AbstractTankValve valve, World world) {
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.enableCull();
    GlStateManager.doPolygonOffset(-3.0F, -3.0F);
    GlStateManager.enablePolygonOffset();

    BlockPos valvePos = valve.getPos();

    List<BlockPos> tankBlocks = FancyFluidStorage.tankManager.getFrameBlocksForValve(valve);
    tankBlocks.add(valvePos);

    Tessellator tess = Tessellator.getInstance();
    VertexBuffer vb = tess.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    vb.setTranslation(-playerX, -playerY, -playerZ);

    for(BlockPos pos : tankBlocks) {
        if(playerPos.distanceSq(pos) > 20)
            continue;

        IBlockState state = world.getBlockState(pos);
        for(BlockRenderLayer layer : renderLayers) {
            if(state.getBlock().canRenderInLayer(state, layer)) {
                ForgeHooksClient.setRenderLayer(layer);
                mc.getBlockRendererDispatcher().renderBlockDamage(state, pos, overlayTexture, world);
            }
        }
    }

    tess.draw();
    vb.setTranslation(0, 0, 0);

    GlStateManager.doPolygonOffset(0.0F, 0.0F);
    GlStateManager.disablePolygonOffset();
    GlStateManager.disableCull();
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
项目:placementpreview    文件:RenderEventHandler.java   
private void renderGhostBlock(final World fakeWorld, ModelHolder holder, final EntityPlayer player, final float partialTicks)
{
    boolean existingModel = this.mc.world.isAirBlock(holder.pos) == false;

    if (Configs.renderOverlapping == false && existingModel)
    {
        return;
    }

    IBlockState actualState = holder.actualState;
    Block block = actualState.getBlock();

    if (actualState.getRenderType() == EnumBlockRenderType.MODEL/* || actualState.getRenderType() == EnumBlockRenderType.LIQUID*/)
    {
        BlockRenderLayer originalLayer = MinecraftForgeClient.getRenderLayer();

        for (BlockRenderLayer layer : BlockRenderLayer.values())
        {
            if (block.canRenderInLayer(actualState, layer))
            {
                this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
                ForgeHooksClient.setRenderLayer(layer);
                this.renderGhostBlock(fakeWorld, holder, player, layer, existingModel, partialTicks);
            }
        }

        ForgeHooksClient.setRenderLayer(originalLayer);
    }
}
项目:Aether-Legacy    文件:AetherEntityRenderingRegistry.java   
@SuppressWarnings("deprecation")
public static void registerTileEntities()
{
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTreasureChest.class, new TreasureChestRenderer());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChestMimic.class, new ChestMimicRenderer());

    ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(BlocksAether.treasure_chest), 0, TileEntityTreasureChest.class);
    ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(BlocksAether.chest_mimic), 0, TileEntityChestMimic.class);
}
项目:Qbar    文件:FlattenedModelCache.java   
private FlattenedModelCache()
{
    this.cache = CacheBuilder.newBuilder().weakKeys().expireAfterAccess(10, TimeUnit.MINUTES)
            .build(new CacheLoader<IBakedModel, IBakedModel>()
            {
                @Override
                public IBakedModel load(final IBakedModel key)
                {
                    IBakedModel model = ForgeHooksClient.handleCameraTransforms(key,
                            ItemCameraTransforms.TransformType.GUI, false);

                    if (model.isGui3d() && !model.isBuiltInRenderer())
                    {
                        model = ModelTransformer.transform(model, null, 0, (quad, element, data) ->
                        {
                            if (element.getUsage() == VertexFormatElement.EnumUsage.NORMAL)
                            {
                                data[0] /= 1.5f;
                                data[2] *= 1.7f;
                            }
                            return data;
                        });
                    }
                    return model;
                }
            });
}
项目:Qbar    文件:RenderUtil.java   
public static final void renderMultiblock(final IBlockState state, final double x, final double y, final double z,
                                          final BlockRendererDispatcher blockRender, final List<BakedQuad> alphaQuads,
                                          final VisibilityModelState opaqueState)
{
    final Minecraft minecraft = Minecraft.getMinecraft();

    minecraft.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    ForgeHooksClient.setRenderLayer(BlockRenderLayer.CUTOUT);

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

    GlStateManager.color(1f, 1f, 1f, 1f);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.enableTexture2D();

    final IBakedModel model = blockRender.getModelForState(state);

    blockRender.getBlockModelRenderer().renderModelBrightnessColor(
            ((BlockMultiblockBase) state.getBlock()).getGhostState(state, opaqueState), model, 1, 1, 1, 1);

    final int alpha = (int) (0.6 * 0xFF) << 24;
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    RenderUtil.renderQuads(alphaQuads, alpha);

    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
项目:AdvancedRocketry    文件:RocketEventHandler.java   
@SubscribeEvent
public void onRocketDeorbit(RocketEvent.RocketDeOrbitingEvent event) {
    if(event.world.isRemote) {
        prepareOrbitalMap(event);

        //Sky blend color gets stuck and doesnt update unless a new X/Z coord is passed
        //So fix that...
        ForgeHooksClient.getSkyBlendColour(event.world, 0, 0, 0);

        if(!(event.world.provider instanceof IPlanetaryProvider)) {
            prevRenderHanlder = event.world.provider.getSkyRenderer();
            event.world.provider.setSkyRenderer(new RenderPlanetarySky());
        }
    }
}
项目:Cauldron    文件:EntityPlayerSP.java   
public float getFOVMultiplier()
{
    float f = 1.0F;

    if (this.capabilities.isFlying)
    {
        f *= 1.1F;
    }

    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    f = (float)((double)f * ((iattributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));

    if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f))
    {
        f = 1.0F;
    }

    if (this.isUsingItem() && this.getItemInUse().getItem() == Items.bow)
    {
        int i = this.getItemInUseDuration();
        float f1 = (float)i / 20.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
        }
        else
        {
            f1 *= f1;
        }

        f *= 1.0F - f1 * 0.15F;
    }

    return ForgeHooksClient.getOffsetFOV(this, f);
}
项目:Cauldron    文件:EntityPlayerSP.java   
public float getFOVMultiplier()
{
    float f = 1.0F;

    if (this.capabilities.isFlying)
    {
        f *= 1.1F;
    }

    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    f = (float)((double)f * ((iattributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));

    if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f))
    {
        f = 1.0F;
    }

    if (this.isUsingItem() && this.getItemInUse().getItem() == Items.bow)
    {
        int i = this.getItemInUseDuration();
        float f1 = (float)i / 20.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
        }
        else
        {
            f1 *= f1;
        }

        f *= 1.0F - f1 * 0.15F;
    }

    return ForgeHooksClient.getOffsetFOV(this, f);
}
项目:ZeldaSwordSkills    文件:ModelItemBombBag.java   
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
    ForgeHooksClient.handleCameraTransforms(baseModel, cameraTransformType);
    if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) {
        return Pair.of(new ModelItemBombBagGui(baseModel, bombsHeld), null);
    }
    return Pair.of(this, null);
}
项目:RuneCraftery    文件:EntityPlayerSP.java   
/**
 * Gets the player's field of view multiplier. (ex. when flying)
 */
public float getFOVMultiplier()
{
    float f = 1.0F;

    if (this.capabilities.isFlying)
    {
        f *= 1.1F;
    }

    AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    f = (float)((double)f * ((attributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));

    if (this.isUsingItem() && this.getItemInUse().itemID == Item.bow.itemID)
    {
        int i = this.getItemInUseDuration();
        float f1 = (float)i / 20.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
        }
        else
        {
            f1 *= f1;
        }

        f *= 1.0F - f1 * 0.15F;
    }

    return ForgeHooksClient.getOffsetFOV(this, f);
}
项目:RuneCraftery    文件:RenderItem.java   
/**
 * Render the item's icon or block into the GUI, including the glint effect.
 */
public void renderItemAndEffectIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
    if (par3ItemStack != null)
    {
        if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float)par4, (float)par5))
        {
            this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
        }

        /* Modders must handle this themselves if they use custom renderers!
        if (par3ItemStack.hasEffect())
        {
            GL11.glDepthFunc(GL11.GL_GREATER);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDepthMask(false);
            par2TextureManager.bindTexture(RES_ITEM_GLINT);
            this.zLevel -= 50.0F;
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
            this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);
            this.zLevel += 50.0F;
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
        */
    }
}
项目:carpentersblocks    文件:BlockCoverable.java   
@Override
/**
 * Determines if this block should render in this pass.
 */
public boolean canRenderInPass(int pass)
{
    ForgeHooksClient.setRenderPass(pass);
    return true;
}
项目:Battlegear2    文件:BattlegearRenderHelper.java   
public static Pair<Boolean, ModelBiped> getEquippedModel(EntityPlayer player, RenderPlayer render, EntityEquipmentSlot slot) {
    ItemStack equip = player.getItemStackFromSlot(slot);
    boolean hasEquip = !equip.isEmpty();
    if (hasEquip) {
        for (Object object : render.layerRenderers) {
            if (object instanceof LayerArmorBase && ((LayerArmorBase) object).getModelFromSlot(slot) instanceof ModelBiped) {
                return Pair.of(true, ForgeHooksClient.getArmorModel(player, equip, slot, (ModelBiped)((LayerArmorBase) object).getModelFromSlot(slot)));
            }
        }
    }
    return Pair.of(hasEquip, null);
}
项目:BetterNutritionMod    文件:EntityPlayerSP.java   
/**
 * Gets the player's field of view multiplier. (ex. when flying)
 */
public float getFOVMultiplier()
{
    float f = 1.0F;

    if (this.capabilities.isFlying)
    {
        f *= 1.1F;
    }

    AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    f = (float)((double)f * ((attributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));

    if (this.isUsingItem() && this.getItemInUse().itemID == Item.bow.itemID)
    {
        int i = this.getItemInUseDuration();
        float f1 = (float)i / 20.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
        }
        else
        {
            f1 *= f1;
        }

        f *= 1.0F - f1 * 0.15F;
    }

    return ForgeHooksClient.getOffsetFOV(this, f);
}
项目:BetterNutritionMod    文件:RenderItem.java   
/**
 * Render the item's icon or block into the GUI, including the glint effect.
 */
public void renderItemAndEffectIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
    if (par3ItemStack != null)
    {
        if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float)par4, (float)par5))
        {
            this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
        }

        /* Modders must handle this themselves if they use custom renderers!
        if (par3ItemStack.hasEffect())
        {
            GL11.glDepthFunc(GL11.GL_GREATER);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDepthMask(false);
            par2TextureManager.bindTexture(RES_ITEM_GLINT);
            this.zLevel -= 50.0F;
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
            this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);
            this.zLevel += 50.0F;
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
        */
    }
}
项目:OpenBlocks    文件:ClientProxy.java   
@SuppressWarnings("deprecation")
private static void registerTrophyItemRenderer(Item item, Trophy trophy) {
    // this is probably enough to revoke my modding licence!
    final Class<? extends TileEntityTrophy> markerCls = MarkerClassGenerator.instance.createMarkerCls(TileEntityTrophy.class);
    final int meta = trophy.ordinal();
    ForgeHooksClient.registerTESRItemStack(item, meta, markerCls);
    ClientRegistry.bindTileEntitySpecialRenderer(markerCls, new TileEntityTrophyRenderer(trophy));
    ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(OpenBlocks.location("trophy"), "inventory"));
}
项目:OpenBlocks    文件:ClientProxy.java   
@SuppressWarnings("deprecation")
private static void registerTesrItemRenderers() {
    visitTesrBlocks(new BlockConsumer() {
        @Override
        public void nomNom(OpenBlock block) {
            Item item = Item.getItemFromBlock(block);
            ForgeHooksClient.registerTESRItemStack(item, 0, block.getTileClass());
        }
    });
}
项目:Andrew2448PowersuitAddons    文件:RenderItemCopy.java   
/**
 * Render the item's icon or block into the GUI, including the glint effect.
 */
public void renderItemAndEffectIntoGUI (SmallFontRenderer par1SmallFontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5)
{
    if (par3ItemStack != null)
    {
        if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2RenderEngine, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5))
        {
            this.renderItemIntoGUI(par1SmallFontRenderer, par2RenderEngine, par3ItemStack, par4, par5);
        }

        if (par3ItemStack.hasEffect())
        {
            GL11.glDepthFunc(GL11.GL_GREATER);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDepthMask(false);
            par2RenderEngine.bindTexture("%blur%/misc/glint.png");
            this.zLevel -= 50.0F;
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
            this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);
            this.zLevel += 50.0F;
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }
}
项目:EnderIO    文件:TravelEntitySpecialRenderer.java   
private void renderItemLabel(@Nonnull ItemStack itemLabel, double globalScale) {
  if (!itemLabel.isEmpty()) {
    RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
    RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();

    GlStateManager.pushMatrix();
    GlStateManager.translate(0.5f, 0.75f, 0.5f);
    // TODO: This doesn't work that well with 3D items, find a rotation that does
    GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate((renderManager.options.thirdPersonView == 2 ? -1 : 1) * renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(globalScale, globalScale, globalScale);
    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);

    RenderHelper.enableStandardItemLighting();

    IBakedModel bakedmodel = itemRenderer.getItemModelWithOverrides(itemLabel, (World) null, (EntityLivingBase) null);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR, GlStateManager.SourceFactor.ONE.factor,
        GlStateManager.DestFactor.ZERO.factor);
    GL14.glBlendColor(itemBlend.x, itemBlend.y, itemBlend.z, itemBlend.w);
    bakedmodel = ForgeHooksClient.handleCameraTransforms(bakedmodel, ItemCameraTransforms.TransformType.GUI, false);
    itemRenderer.renderItem(itemLabel, NullHelper.notnullF(bakedmodel, "handleCameraTransforms returned null!"));

    RenderHelper.disableStandardItemLighting();

    GL14.glBlendColor(1, 1, 1, 1);
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.popMatrix();
  }
}
项目:EnderIO    文件:TravelEntitySpecialRenderer.java   
public void renderBlock(@Nonnull BlockPos pos, IBlockAccess blockAccess, double globalScale, boolean highlight) {
  VertexBuffer tes = Tessellator.getInstance().getBuffer();
  BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();

  GlStateManager.pushMatrix();
  GlStateManager.translate(0.5f, 0.5f, 0.5f);
  GlStateManager.scale(globalScale, globalScale, globalScale);
  GlStateManager.translate(-0.5f, -0.5f, -0.5f);
  IBlockState state = blockAccess.getBlockState(pos).getActualState(blockAccess, pos);
  IBakedModel ibakedmodel = blockrendererdispatcher.getModelForState(state);
  state = state.getBlock().getExtendedState(state, blockAccess, pos);

  tes.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
  Vector4f color = highlight ? selectedBlockBlend : blockBlend;

  GlStateManager.color(1, 1, 1, 1);
  GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR, GlStateManager.SourceFactor.ONE.factor,
      GlStateManager.DestFactor.ZERO.factor);
  GL14.glBlendColor(color.x, color.y, color.z, color.w);

  tes.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
  for (BlockRenderLayer layer : BlockRenderLayer.values()) {
    if (state.getBlock().canRenderInLayer(state, NullHelper.notnullJ(layer, "BlockRenderLayer value was null!"))) {
      ForgeHooksClient.setRenderLayer(layer);
      blockrendererdispatcher.getBlockModelRenderer().renderModel(blockAccess, ibakedmodel, state, pos, tes, false);
    }
  }
  ForgeHooksClient.setRenderLayer(null);
  Tessellator.getInstance().draw();

  GL14.glBlendColor(1, 1, 1, 1);
  GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  tes.setTranslation(0, 0, 0);

  GlStateManager.popMatrix();
}