Jump to content

[SOLVED] - [1.15.1] Rendering - How to determine "canRenderInLayer" based on block state.


Recommended Posts

Posted (edited)

So I started the update from 1.14.4 to 1.15.1 and got stuck pretty early with the rendering changes. I have a block which changes it's visual state when it receives a redstone signal. 

This doesn't seem to work well with the new code layout.

 

I found that I have to use RenderTypeLookup#setRenderLayer now instead of overriding a method on my block, good.

However while reviewing that class (RenderTypeLookup) I noticed the "canRenderInLayer" method does nothing with the block state passed in except get the block associated with the state.

 

client setup method

	@Override
	public void clientSetup(FMLClientSetupEvent clientSetupEvent) {
		RenderTypeLookup.setRenderLayer(ModRegistry.BoundaryBlock(), BlockBoundary::canRenderInLayer);
	}

 

RenderTypeLookup#canRenderInLayer - This is called in chunk rendering.

   public static boolean canRenderInLayer(BlockState state, RenderType type) {
      Block block = state.getBlock();
      if (block instanceof LeavesBlock) {
         return field_228388_c_ ? type == RenderType.func_228641_d_() : type == RenderType.func_228639_c_();
      } else {
         java.util.function.Predicate<RenderType> rendertype;
         synchronized (RenderTypeLookup.class) {
             rendertype = blockRenderChecks.get(block);
         }
         return rendertype != null ? rendertype.test(type) : type == RenderType.func_228639_c_();
      }
   }

 

BlockBoundary#canRenderInLayer

	/**
	 * Queries if this block should render in a given layer.
	 */
	public static boolean canRenderInLayer(Object layer) {
		// NOTE: This code is in a partial state. Need to find out how to get block state to determine if the block should be rendered this pass.
		boolean powered = false;// state.get(Powered);

		RenderState renderState = (RenderState)layer;

		// first part is translucent, second is for solid.
		return (layer == RenderType.func_228645_f_() && !powered) || (layer == RenderType.func_228639_c_() && powered);
	}

 

 

I was using the canRenderInLayer method as a shortcut so the model wouldn't have to be loaded (trying to be efficient).

So I guess my question would be. Should I even worry about this or is there a hook or something that I can use instead?

 

Note: I have another block which becomes invisible if it receives a redstone signal (changes block state) or if it's interacted with (it phases out and then back in).

 

Any help or ideas would be appreciated!

 

Thank you!

Edited by WuestMan
Solved issue myself

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.