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