Xcisso Posted May 31, 2018 Posted May 31, 2018 (edited) 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. Edited May 31, 2018 by Xcisso Added screenshot Quote
Draco18s Posted May 31, 2018 Posted May 31, 2018 Blocks are made of models. Models have 1 or more textures. Which texture do you want? 1 Quote 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.
Xcisso Posted May 31, 2018 Author Posted May 31, 2018 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. Quote
V0idWa1k3r Posted May 31, 2018 Posted May 31, 2018 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. 1 Quote
Xcisso Posted May 31, 2018 Author Posted May 31, 2018 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? ? Quote
V0idWa1k3r Posted May 31, 2018 Posted May 31, 2018 The field is public. just bind 1 hour ago, V0idWa1k3r said: TextureMap.LOCATION_BLOCKS_TEXTURE Then use the UVs from the TextureAtlasSprite when making vertices with the BufferBuilder. 1 Quote
Xcisso Posted May 31, 2018 Author Posted May 31, 2018 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 Quote
Recommended Posts
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.