Jump to content

Using an already existing block texture


Xcisso

Recommended Posts

Hello!

Im trying to get a texture from a block, and use a Render class to render a quad in the world with that texture on it.

I have everything except how to actually find a block in the world, and get its texture to use in the render class.

 

this is what ive got so far, i need the resourcelocation from the blocks model texture. And i cant for the life of me figure out how to get it..

//IBakedModel bakedModel = mc.getRenderItem().getItemModelWithOverrides(stack, entity.world, mc.player);
IBakedModel bakedModel = mc.getBlockRendererDispatcher().getModelForState(waypoint.blockType.getDefaultState());
TextureAtlasSprite sprite = bakedModel.getQuads(waypoint.blockState, EnumFacing.EAST, 0).get(0).getSprite();


this.bindTexture(new ResourceLocation(sprite.getIconName())); 	//This is where i need the resource location.. I already got a block and 
																//blockstate and everything else imaginable, except for the resource location.

 

 

So far ive tried to create a new ResourceLocation with the name of the blocks texture, but i get a FileNotFound exception, and a black and pink square as shown in the screenshot.

 

Im not sure if i should create a new ResourceLocation, or get one from the blocks model?

 

Also not that everything works exactly like i want it with text and textures that i create. Just not when i try to grab a texture from a block.

screenshot_01.png

Edited by Xcisso
Added screenshot
Link to comment
Share on other sites

Blocks are made of models.

Models have 1 or more textures.

Which texture do you want?

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, Draco18s said:

Blocks are made of models.

Models have 1 or more textures.

Which texture do you want?

 

Any. I want to be able to get access to the block's textures And choose the one I want.

 

If you look at my example with the sprite.getIconName(), I end up with a string "minecraft:blocks/sandstone_top", (or _side)

 

If I try to use that string in a new resourcelocation, and bind it, I get a file not found exception. 

 

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

All sprites(blocks & items) are stored in one texture which is TextureMap.LOCATION_BLOCKS_TEXTURE. TextureAtlasSprite contains the UV coordinates for that sprite on this texture.

 Yea, and how would I access that texture? ?

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

The field is public. just bind 

Then use the UVs from the TextureAtlasSprite when making vertices with the BufferBuilder.

 

 

oh, im sorry! I read your answer on my mobile, and didnt see you mentioning the TextureMap.LOCATION.

 

Thank you very much, this was a bit of a pain to figure out! 

 

Its been 4 years since i touched minecraft modding, so it takes a bit of trying and failing to get back into it.

 

Also, thanks for the quick reply, this has caused me a bit of a headache today :D

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.