Search in sources :

Example 31 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project CodeChickenLib by Chicken-Bones.

the class RenderUtils method renderFluidCuboid.

/**
     * Renders a fluid within a bounding box.
     * If the fluid is a liquid it will render as a normal tank with height equal to density/bound.height.
     * If the fluid is a gas, it will render the full box with an alpha equal to density.
     * Warning, bound will be mutated if the fluid is a liquid
     *
     * @param stack   The fluid to render.
     * @param bound   The box within which the fluid is contained.
     * @param density The volume of fluid / the capacity of the tank. For gases this determines the alpha, for liquids this determines the height.
     * @param res     The resolution to render at.
     */
public static void renderFluidCuboid(FluidStack stack, Cuboid6 bound, double density, double res) {
    if (!shouldRenderFluid(stack))
        return;
    int alpha = 255;
    if (stack.getFluid().isGaseous())
        alpha = (int) (fluidDensityToAlpha(density) * 255);
    else
        bound.max.y = bound.min.y + (bound.max.y - bound.min.y) * density;
    TextureAtlasSprite tex = prepareFluidRender(stack, alpha);
    CCRenderState.startDrawing();
    renderFluidCuboid(bound, tex, res);
    CCRenderState.draw();
    postFluidRender();
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 32 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.

the class RenderPeripheral method renderBase.

private void renderBase(ITessellator tessellator) {
    final TextureAtlasSprite iconTop = this.getIcon(TEXTURE_TOP);
    final TextureAtlasSprite iconSide = this.getIcon(TEXTURE_SIDE);
    final TextureAtlasSprite iconBottom = this.getIcon(TEXTURE_BOTTOM);
    final TextureAtlasSprite iconInside = this.getIcon(TEXTURE_INNER);
    float unit = Constants.UNIT;
    //top
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.UP, iconTop, 1);
    //bottom
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.DOWN, iconBottom, 0);
    //front
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, iconSide, 0);
    //right
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.EAST, iconSide, 1);
    //left
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.WEST, iconSide, 0);
    //back
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.SOUTH, iconSide, 1);
    //inside top
    tessellator.drawScaledFace(4, 4, 12, 12, EnumFacing.UP, iconBottom, 12 * unit);
    //inside front
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, iconInside, 4 * unit);
    //inside right
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.EAST, iconInside, 12 * unit);
    //inside left
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.WEST, iconInside, 4 * unit);
    //inside back
    tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.SOUTH, iconInside, 12 * unit);
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 33 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.

the class PlantRenderer method renderPlant.

public static void renderPlant(@Nonnull ITessellator tessellator, @Nonnull IAgriPlant plant, int growthStage) {
    TextureAtlasSprite iconA = tessellator.getIcon(plant.getPrimaryPlantTexture(growthStage));
    TextureAtlasSprite iconB = tessellator.getIcon(plant.getSecondaryPlantTexture(growthStage));
    if (iconA == null) {
        iconB = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
    }
    if (iconB == null) {
        iconB = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
    }
    if (iconA != null) {
        switch(plant.getRenderMethod()) {
            case CROSSED:
                renderCrossPattern(tessellator, iconA, 0);
                break;
            case HASHTAG:
                renderHashTagPattern(tessellator, iconA, 0);
                break;
            case STEM:
                renderStemPlant(tessellator, iconA, iconB, growthStage);
                break;
            case TALL_CROSSED:
                renderCrossPattern(tessellator, iconA, 0);
                if (iconB != null) {
                    renderCrossPattern(tessellator, iconA, 1);
                }
                break;
            case TALL_HASHTAG:
                renderHashTagPattern(tessellator, iconA, 0);
                if (iconB != null) {
                    renderHashTagPattern(tessellator, iconA, 1);
                }
                break;
        }
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 34 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.

the class RenderWaterPad method renderInventoryBlock.

@Override
public void renderInventoryBlock(ITessellator tess, World world, IBlockState state, BlockWaterPad block, ItemStack stack, EntityLivingBase entity, ItemCameraTransforms.TransformType type) {
    // Icons
    final TextureAtlasSprite matIcon = BaseIcons.DIRT.getIcon();
    final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();
    // Draw Base
    renderBase(tess, matIcon);
    // Draw Sides
    for (EnumFacing dir : EnumFacing.HORIZONTALS) {
        renderSide(tess, dir, matIcon);
    }
    // Full
    if (AgriProperties.POWERED.getValue(state)) {
        renderWater(tess, waterIcon);
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing)

Example 35 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project Bookshelf by Darkhax-Minecraft.

the class RenderUtils method renderFluid.

/**
     * Renders a fluid at the given position.
     *
     * @param fluid The fluid to render.
     * @param pos The position in the world to render the fluid.
     * @param x The base X position.
     * @param y The base Y position.
     * @param z The base Z position.
     * @param x1 The middle X position.
     * @param y1 The middle Y position.
     * @param z1 The middle Z position.
     * @param x2 The max X position.
     * @param y2 The max Y position.
     * @param z2 The max Z position.
     * @param color The color offset used by the fluid. Default is white.
     */
public static void renderFluid(FluidStack fluid, BlockPos pos, double x, double y, double z, double x1, double y1, double z1, double x2, double y2, double z2, int color) {
    final Minecraft mc = Minecraft.getMinecraft();
    final Tessellator tessellator = Tessellator.getInstance();
    final VertexBuffer buffer = tessellator.getBuffer();
    final int brightness = mc.world.getCombinedLight(pos, fluid.getFluid().getLuminosity());
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    setupRenderState(x, y, z);
    GlStateManager.translate(x, y, z);
    final TextureAtlasSprite still = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getStill(fluid).toString());
    final TextureAtlasSprite flowing = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getFlowing(fluid).toString());
    addTexturedQuad(buffer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness);
    addTexturedQuad(buffer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness);
    tessellator.draw();
    cleanupRenderState();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Minecraft(net.minecraft.client.Minecraft)

Aggregations

TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)51 ResourceLocation (net.minecraft.util.ResourceLocation)9 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)8 EnumFacing (net.minecraft.util.EnumFacing)8 Tessellator (net.minecraft.client.renderer.Tessellator)6 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)5 IBlockState (net.minecraft.block.state.IBlockState)5 TileEntity (net.minecraft.tileentity.TileEntity)5 UnpackedBakedQuad (net.minecraftforge.client.model.pipeline.UnpackedBakedQuad)5 Minecraft (net.minecraft.client.Minecraft)4 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 Vector3f (org.lwjgl.util.vector.Vector3f)4 ImmutableList (com.google.common.collect.ImmutableList)3 HashMap (java.util.HashMap)3 TransformType (net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)3 TextureManager (net.minecraft.client.renderer.texture.TextureManager)3 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)3