Jump to content

BlockState not updating


Musicgun47

Recommended Posts

I have just started working on a mod for the first time so apologies if the solution is really obvious.

 

I'm trying to make a table that when placed next to another will connect into one block. I only want them to connect in a straight line, so not around corners. I have set up a blockstate JSON for all the variants which works properly for the single table (i.e. rotating the table to face the player) and overrided the neighborChanged method to check for adjacent tables and connect if possible. However, when I test it in game the blockstates are not updating when the tables are placed side by side. not sure what I'm doing wrong but hopefully someone else can spot the error.

 

AlchemistsTable class    AlchemistsTable BlockState

Link to comment
Share on other sites

58 minutes ago, Musicgun47 said:

I have just started working on a mod for the first time so apologies if the solution is really obvious.

 

I'm trying to make a table that when placed next to another will connect into one block. I only want them to connect in a straight line, so not around corners. I have set up a blockstate JSON for all the variants which works properly for the single table (i.e. rotating the table to face the player) and overrided the neighborChanged method to check for adjacent tables and connect if possible. However, when I test it in game the blockstates are not updating when the tables are placed side by side. not sure what I'm doing wrong but hopefully someone else can spot the error.

 

AlchemistsTable class    AlchemistsTable BlockState

You do not have all of your variants outlined. West can be true or false, but so can all your other boolean properties, now that means they can be false and another can be true. So you actually have a block with 2^4 different possibilities with just the boolean properties.

 

Also this will never be true.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

9 hours ago, Animefan8888 said:

You do not have all of your variants outlined. West can be true or false, but so can all your other boolean properties, now that means they can be false and another can be true. So you actually have a block with 2^4 different possibilities with just the boolean properties.

I only defined the variants that should be possible. If the undefined variants ever occur, minecraft would just render the black and puple cube, but this never happens as the boolean values are never changed. Also I'm removing the booleans entirely as I realised I didn't need them for determining where the connections are.

9 hours ago, Animefan8888 said:

Also this will never be true.

This method should be checking if a table can connect on a specific side. By default it will return true as the default state of the table is connections == 0. It should return false if the table already has at least 1 connection and the table is facing the direction it's trying to connect to.

Link to comment
Share on other sites

19 minutes ago, Musicgun47 said:
10 hours ago, Animefan8888 said:

Also this will never be true.

This method should be checking if a table can connect on a specific side. By default it will return true as the default state of the table is connections == 0. It should return false if the table already has at least 1 connection and the table is facing the direction it's trying to connect to.

No no.

THIS will never be true:

worldIn.getBlockState(pos.offset(facing)) instanceof AlchemistsTable

getBlockState() returns an IBlockState and AlchemistTable is a Block. An IBlockState will never equal a Block.

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

Oh, apparently I'm an idiot and didn't even notice I'd done that. ?

 

Well, I changed the class to fix that and removed the unnecessary properties, but it's still using the old implementation in game, which now always displays the purple and black box. Not sure what I've done wrong. I did switch to the forge json format but that shouldn't be the problem.

Links at top still relevant.

Link to comment
Share on other sites

1 hour ago, Musicgun47 said:

Well, I changed the class to fix that and removed the unnecessary properties, but it's still using the old implementation in game, which now always displays the purple and black box. Not sure what I've done wrong. I did switch to the forge json format but that shouldn't be the problem.

Post the log.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

6 minutes ago, Musicgun47 said:

Here's the log, but I can't see any errors, aside from missing textures for other items i haven't created yet.

Is it the full cube or does it have your model. I am assuming it doesn't have your model, was this from a fresh run of the dev environment.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

It's the full cube, and yes, this was from a fresh run.

 

The problem is that Minecraft is looking for the variant that has the boolean flags for north, south east and west, which don't exist because I removed them from the class. However it still thinks that the block should have those properties.

Link to comment
Share on other sites

2 minutes ago, Musicgun47 said:

The problem is that Minecraft is looking for the variant that has the boolean flags for north, south east and west, which don't exist because I removed them from the class. However it still thinks that the block should have those properties.

No Minecraft won't look for any variants it is not told about. Try creating a new world.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Ok, I feel like a complete idiot now. Turns out when I configured the git repository, it stopped updating changes to the local workspace that eclipse was set to build from. Fixed it now by changing the build location to the local git repository and everything works now. Just need to fix the bugs now.

 

Thanks for the help.

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.