Jump to content

[1.16] How to render water in screen


Zemelua

Recommended Posts

I have created a Container with a FluidTank Slot. In order to draw this on the Screen, I need to get the texture of the Fluid and draw it transparently in the case of water.
1. How do I get the texture of a fluid?
2. How can I draw transparent (and animate) water?

Link to comment
Share on other sites

I did a little research and coded it with reference to the mod that draws the liquid in the GUI in the same way, but the liquid is not drawn, only the noise-like thing is displayed small. What's wrong?

~~

private void renderFluid(MatrixStack matrixStack, Tank tank) {
	int x = tank.getXPos();
	int y = tank.getYPos();
	FluidStack fluidStack = tank.getStack();
	this.minecraft.getTextureManager().bindTexture(
			this.minecraft.getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE).apply(
					fluidStack.getFluid().getAttributes().getStillTexture(fluidStack)
			).getAtlasTexture().getTextureLocation()
	);
	AbstractGUI.blit(matrixStack, x, y, this.getBlitOffset(), 0, 0, 16, 16, 16, 16);
}

~~
Link to comment
Share on other sites

private void renderFluid(MatrixStack matrixStack, Tank tank) {
	// 33;
	int x = tank.getXPos();
	int y = tank.getYPos();

	// FluidStack fluidStack = tank.getStack();
	FluidStack fluidStack = new FluidStack(Fluids.WATER, 1);
	TextureAtlasSprite fluidSprite = this.minecraft.getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE)
			.apply(fluidStack.getFluid().getAttributes().getStillTexture(fluidStack)
			);
		
	if (!fluidStack.isEmpty()) {
		this.minecraft.getTextureManager().bindTexture(
				fluidSprite.getAtlasTexture().getTextureLocation()
		);
	}
	AbstractGui.blit(matrixStack, this.guiLeft + x, this.guiTop + y, this.getBlitOffset(), 16, 16, fluidSprite);
}

I was able to draw the texture of water for the time being. However, I haven't drawn the overlay yet, so it remains gray. How do I apply the overlay to make it blue?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.