Jump to content

How should I handle a chessboard which needs way too many blockstates?


Baybird

Recommended Posts

Basically I'm making a chessboard. On it, you have each of the pieces which you can move independently of each other. The chessboard only takes up one block of space. Obviously I CANNOT make a blockstate for each playable position on a chessboard. What kind of system do I use then? I'd like to have each space on a chessboard essentially have it's own blockstate so that they behave as if they are each their own block. Or maybe there's a way to combine block states? Of course the effect I'm trying to achieve can be done but how should the underlying functionality accomplish this?

Link to comment
Share on other sites

If you have too many BlockStates you can render the Block by yourself using a BlockEntityRenderer.

I have never done this myself, but you could look at the vanilla chest as an example of how a block/model is rendered.
But I can't promise you that this is the right direction to do this.

Link to comment
Share on other sites

Okay, yeah that solves needing a ton of block states. I suppose I could just use some block properties to describe what pieces are where and then just render the chessboard based on those properties. Awesome! Still, how might I make the pieces placeable? Here's my idea (tell me if it's dumb). If the player is holding a piece and right clicks the chessboard, a raycast is preformed which is used to determine what chess piece or space the player is actually clicking. Then I can set the chessboard properties accordingly and and render it. Good idea, or is there a more simple approach?

Link to comment
Share on other sites

On 10/31/2023 at 2:55 AM, Baybird said:

I suppose I could just use some block properties to describe what pieces are where and then just render the chessboard based on those properties.

Note, you need to store those block properties per block which means it requires a BlockEntity

 

On 10/31/2023 at 2:55 AM, Baybird said:

If the player is holding a piece and right clicks the chessboard, a raycast is preformed which is used to determine what chess piece or space the player is actually clicking.

Minecraft provides no other way to do this. You can take a look at the ChiseledBookShelfBlock for an vanilla example how to clip/raycast a position on a Block.

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.