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();
}
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);
}
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;
}
}
}
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);
}
}
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();
}
Aggregations