Jump to content

Recommended Posts

Posted

I have a storage block/container/tesr that allows the user to add any block to a single slot in the gui.

 

I need to obtain the texture of the block dropped into the slot for rendering in the TESR.

 

How can the texture be obtained in 1.8?

 

Also, is this the correct texture to assign?

 

this.renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture);

 

Thanks.

Posted

That should be the stitched texture sheet, yes.  You'll still need to bind the texture (making sure that OGL is drawing with the right texture) and get the UV coordinates from the block's IIcon (to draw the correct portion).

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.

Posted

Item item = stack.getItem();
Block block = Block.getBlockFromItem(item);
block.getIcon(side, meta);

 

Note that I didn't attempt to check for null, etc.

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.

Posted

I'm not familiar with 1.8, unfortunately.

 

You'll have to dig around to figure out how Minecraft's renderer (RenderGlobal?) figures that out.  The whole json thing irks me, TBH.  I mean, I get why it exists, so that resource packs can alter the shapes of blocks as well as the texture, but the implementation lost something in the process.

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.

Posted

I think this is the way to get what I am looking for...

 

Minecraft mc = Minecraft.getMinecraft();
IBlockState blockState = Block.getStateById(Block.getIdFromBlock(block));
BlockRendererDispatcher blockRendererDispatcher = mc.getBlockRendererDispatcher();
BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes();
IFlexibleBakedModel bakedModel = (IFlexibleBakedModel)blockModelShapes.getModelForState(blockState);
TextureAtlasSprite sprite = bakedModel.getTexture();
int textureX = sprite.getOriginX();
int textureY = sprite.getOriginY();

 

...anyone know a better way?

Posted

That's likely the best you're going to get. 1.8's rendering is weird and annoying due to the multiple levels of wrappers.

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.

Posted

That would not work in some case, like block models with multiple textures.

Why do you want to obtain texture?

I think you can just display the item. (In this case, something like ItemRenderer#render(IBakedModel) would be sufficient)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I am making a block (#1) that allows the user to select another block (#2) who's texture will be used to render inside of block #1.

 

Item rendering won't work - I need to render many faces in different locations within block #1 - just like I was able to in 1.7.10.

 

My code above does not work - I only get a solid white color on the face I'm rendering rather than the block texture I'm trying to use.

 

And yes, I need to be able to have access to all textures in a block like wool or glass.

Posted

I stored whatever IBlockState the block is supposed to render as as a field in the block's TileEntity, then fetch it in the ISmartBlockModel:

@Override
public IBakedModel handleBlockState(IBlockState state) {
	if (state instanceof IExtendedBlockState) {
		IBlockState renderState = ((IExtendedBlockState) state).getValue(YourBlock.RENDER_STATE_PROPERTY); // obviously you'll have to change this
		if (renderState != null) {
			IBakedModel renderModel = mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(renderState);
			if (renderModel instanceof ISmartBlockModel) {
				renderModel = ((ISmartBlockModel) renderModel).handleBlockState(renderState);
			}
			return renderModel;
		}
	}
	return defaultModel;
}

It works for the 99% of cases, but obviously there will always be some that won't work. Personally, I just use it for solid, cube-shaped blocks.

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.