Search in sources :

Example 1 with RenderTools

use of mods.railcraft.client.render.tools.RenderTools in project Railcraft by Railcraft.

the class FluidModelRenderer method renderFluid.

/**
 * @param level Ranges from 1 to 16 inclusively, 0 will crash
 */
public void renderFluid(FluidStack fluidStack, int level) {
    IBakedModel bakedModel = new FluidModel(fluidStack, false).bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, RenderTools::getTexture);
    Minecraft mc = Minecraft.getMinecraft();
    mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
    Tessellator tess = Tessellator.getInstance();
    BufferBuilder buffer = tess.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    IExtendedBlockState state = (IExtendedBlockState) new ExtendedBlockState(Blocks.WATER, new IProperty[] { BlockFluidBase.LEVEL }, BlockFluidBase.FLUID_RENDER_PROPS.toArray(new IUnlistedProperty<?>[0])).getBaseState();
    for (int i = 0; i < 4; i++) state = state.withProperty(BlockFluidBase.LEVEL_CORNERS[i], level / 16F);
    state = (IExtendedBlockState) state.withProperty(BlockFluidBase.LEVEL, level - 1);
    state = state.withProperty(BlockFluidBase.FLOW_DIRECTION, -1000F);
    putQuads(buffer, bakedModel.getQuads(state, null, 1234));
    for (EnumFacing side : EnumFacing.VALUES) {
        putQuads(buffer, bakedModel.getQuads(state, side, 1234));
    }
    tess.draw();
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IUnlistedProperty(net.minecraftforge.common.property.IUnlistedProperty) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ExtendedBlockState(net.minecraftforge.common.property.ExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) RenderTools(mods.railcraft.client.render.tools.RenderTools) Minecraft(net.minecraft.client.Minecraft)

Aggregations

RenderTools (mods.railcraft.client.render.tools.RenderTools)1 Minecraft (net.minecraft.client.Minecraft)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 EnumFacing (net.minecraft.util.EnumFacing)1 ExtendedBlockState (net.minecraftforge.common.property.ExtendedBlockState)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1 IUnlistedProperty (net.minecraftforge.common.property.IUnlistedProperty)1