Jump to content

[Solved] Texture Atlas Sprite for water is missing texture


Recommended Posts

Posted (edited)

I am getting the TextureAtlasSprite for the Water block in PostInit, because I need the average color value of water in order to draw a minimap. Somehow though, the code is returning the missing texture sprite instead of the water texture sprite. It works for all blocks in the game except for water and lava...

 

This is the code used to get the sprite: 

IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
List<BakedQuad> quads = model.getQuads(state, EnumFacing.UP, 0);
quads.addAll(model.getQuads(state, null, 0));
if(quads.size() == 0) return null;
return quads.get(0).getSprite();

 

Edited by deerangle
Posted

If you want to render fluids use Minecraft.getMinecraft().getBlockRendererDispatcher()#fluidRenderer (Its private you'll have to use reflection)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

I don't think the OP wants to render fluids since they mentioned that they need the sprite for the average color to draw on a minimap.

My solution would be to get the fluid associated with the block if it has one. If the block is LAVA or WATER then default to FluidRegistry.WATER/LAVA respectively, otherwise check if the block is an instance of IFluidBlock and use IFluidBlock#getFluid to obtain the fluid. Then once you know the fluid you can querry the sprite name using Fluid#getStill/getFlowing. Lastly you can now use TextureMap#getAtlasSprite to get the actual sprite(like I do here). You can even get the fluid's color from the fluid by using Fluid#getColor.

  • Like 1

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.