Java Code Examples for net.minecraftforge.fluids.Fluid#getStill()

The following examples show how to use net.minecraftforge.fluids.Fluid#getStill() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluidStackRenderer.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
public static boolean renderFluidStack(FluidStack fluidStack, int x, int y) {
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return false;
    }

    Minecraft mc = Minecraft.getMinecraft();
    TextureMap textureMapBlocks = mc.getTextureMapBlocks();
    ResourceLocation fluidStill = fluid.getStill();
    TextureAtlasSprite fluidStillSprite = null;
    if (fluidStill != null) {
        fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString());
    }
    if (fluidStillSprite == null) {
        fluidStillSprite = textureMapBlocks.getMissingSprite();
    }

    int fluidColor = fluid.getColor(fluidStack);
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    setGLColorFromInt(fluidColor);
    drawFluidTexture(x, y, fluidStillSprite);

    return true;
}
 
Example 2
Source File: Util.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
public static TextureAtlasSprite getTextureFromFluidStack(FluidStack stack)
{
    if(stack.getFluid() != null)
    {
        Fluid fluid = stack.getFluid();
        
        if(fluid.getStill(stack) != null)
        {
            return Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(fluid.getStill().toString());
        }
    }
    
    return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
}
 
Example 3
Source File: GuiComponentTankLevel.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void render(int offsetX, int offsetY, int mouseX, int mouseY) {
	bindComponentsSheet();
	BOX_RENDERER.render(this, x + offsetX, y + offsetY, width, height, BORDER_COLOR);

	if (fluidStack == null) return;
	final Fluid fluid = fluidStack.getFluid();
	if (fluid == null) return;

	parent.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

	final ResourceLocation textureLocation = fluid.getStill(fluidStack);
	TextureAtlasSprite icon = parent.getIcon(textureLocation);

	if (icon != null) {
		double percentFull = Math.max(0, Math.min(1, (double)fluidStack.amount / (double)capacity));
		double fluidHeight = (height - 3) * percentFull;
		final int posX = offsetX + x;
		final int posY = offsetY + y;

		final float minU = icon.getMinU();
		final float maxU = icon.getMaxU();

		final float minV = icon.getMinV();
		final float maxV = icon.getMaxV();

		GL11.glBegin(GL11.GL_QUADS);
		addVertexWithUV(posX + 3, posY + height - 3, this.zLevel, minU, maxV);
		addVertexWithUV(posX + width - 3, posY + height - 3, this.zLevel, maxU, maxV);
		addVertexWithUV(posX + width - 3, posY + (height - fluidHeight), this.zLevel, maxU, minV);
		addVertexWithUV(posX + 3, posY + (height - fluidHeight), this.zLevel, minU, minV);
		GL11.glEnd();
	}
}
 
Example 4
Source File: RenderUtil.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void drawFluidForGui(FluidStack contents, int tankCapacity, int startX, int startY, int widthT, int heightT) {
    widthT--;
    heightT--;
    Fluid fluid = contents.getFluid();
    ResourceLocation fluidStill = fluid.getStill();
    TextureAtlasSprite fluidStillSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(fluidStill.toString());
    int fluidColor = fluid.getColor(contents);
    int scaledAmount = contents.amount * heightT / tankCapacity;
    if (contents.amount > 0 && scaledAmount < 1) {
        scaledAmount = 1;
    }
    if (scaledAmount > heightT) {
        scaledAmount = heightT;
    }
    GlStateManager.enableBlend();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    setGlColorFromInt(fluidColor, 200);

    final int xTileCount = widthT / 16;
    final int xRemainder = widthT - xTileCount * 16;
    final int yTileCount = scaledAmount / 16;
    final int yRemainder = scaledAmount - yTileCount * 16;

    final int yStart = startY + heightT;

    for (int xTile = 0; xTile <= xTileCount; xTile++) {
        for (int yTile = 0; yTile <= yTileCount; yTile++) {
            int width = xTile == xTileCount ? xRemainder : 16;
            int height = yTile == yTileCount ? yRemainder : 16;
            int x = startX + xTile * 16;
            int y = yStart - (yTile + 1) * 16;
            if (width > 0 && height > 0) {
                int maskTop = 16 - height;
                int maskRight = 16 - width;

                drawFluidTexture(x, y, fluidStillSprite, maskTop, maskRight, 0.0);
            }
        }
    }
    GlStateManager.disableBlend();
}
 
Example 5
Source File: RenderHelper.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
public static TextureAtlasSprite getStillTexture(Fluid fluid)
{
    ResourceLocation tex = fluid.getStill();
    return tex == null ? null : Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(tex.toString());
}
 
Example 6
Source File: TextureUtils.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static TextureAtlasSprite getFluidTexture(Fluid fluid) {
	final ResourceLocation textureLocation = fluid.getStill();
	return getTextureAtlasLocation(textureLocation);
}