Jump to content

[SOLVED] [1.10.2] Blockstate change not rendering


MCHellspawn

Recommended Posts

Hello,

 

  New to modding.. Been following several modding tutorials but attempting to make a furnace block in my mod.. I'm just getting to the point of adding a TileEntity to the block.. The TE gets created fine, I have an onblockactived function on the block that updates the TE's "active" property when I right click the block, starting simple.. I also have it start a 200 tick count down.. When I activate the block I want the render of the block to change, much like with the vanilla furnace when it starts cooking.. It's weird because I can see from messages I have writing to the console that the TE is getting updated and is counting down however the block render doesn't get updated.. If I right click the block repeatedly it does update sometimes.. To be honest I can't figure out why it does it sometimes and not others.. Would someone be willing to look at my code and tell me what I am doing wrong?? Any help is greatly appreciated..

 

https://github.com/MCHellspawn/CompressedFurnace

Edited by MCHellspawn
Link to comment
Share on other sites

Try rewriting the block's active / not active manipulation without getting any data from your TE. The blockstate at pos should have all the data you need. The only thing you might need to do to the TE is tell it what the new state is, and you might not even need that (depending on how your TE is ticking).

Edited by jeffryfisher

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

2 hours ago, jeffryfisher said:

Try rewriting the block's active / not active manipulation without getting any data from your TE. The blockstate at pos should have all the data you need. The only thing you might need to do to the TE is tell it what the new state is, and you might not even need that (depending on how your TE is ticking).

First, Thank you for the reply..

 

Second.. I'm a bit confused.. I thought I was handling all of the active manipulation in the block.. I'm setting it in the onblockactivated function, and then in there setting the active property in the TE.. I'm really only doing the TE so I can hold more info about the block later... Are you saying I should do a block state change in there too?

Link to comment
Share on other sites

You either:

a) need to set a block state (make sure to override shouldRefresh in your TE to return false if the block remains the same).

b) need to override getActualState in order to get the state property from TE data.

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

2 minutes ago, Draco18s said:

You either:

a) need to set a block state (make sure to override shouldRefresh in your TE to return false if the block remains the same).

b) need to override getActualState in order to get the state property from TE data.

 Ok... I think I am doing both of those.. setting a blockstate in the onblockactivated, and I've overridden getActualState...

Link to comment
Share on other sites

You need to call World#notifyBlockUpdate from the TileEntity whenever a value used by Block#getActualState changes. This tells the server to send the TileEntity's update packet to any nearby clients as well as telling them to re-draw the chunk containing the block, using the new actual state to select the model.

 

You also need to call World#notifyBlockUpdate from TileEntity#onDataPacket so that the client re-draws the chunk whenever it receives the TileEntity's update packet.

 

You can see an example of a block that uses TileEntity data in Block#getActualState here: BlockColoredRotatable, TileEntityColoredRotatable

  • Like 3

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

21 hours ago, MCHellspawn said:

I thought I was handling all of the active manipulation in the block.

At the time I looked at your block's code, it was fetching the TE to get the value of "active". It shouldn't need to do that. In fact, the TE might not need to hold onto that either. It knows its own pos and should fetch its co-located blockstate to find out (and to verify that the block in place is still the furnace that it belongs with).

 

The block should be able to know it's active by using its own bs / metadata. At most, it should be telling the TE about changes (and Choonster pointed at a useful method).

 

Look at your code where the block decides whether to become active / inactive. Pretend that the TE isn't there to help you (unless the block actually needs TE data about inventory or smelting progress -- but I didn't see any such factor in the decision).

 

Do you see it now? I don't think you need to fetch a TE to tell you that you're active when your own metadata should know that much.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

  • 2 weeks later...

Ok.. I know it's been a bit since this one started but continuing the adventure..

 

Before moving on to container and GUI I wanted to work on your suggestions.. I've made some changes to the block and TE to get it more towards the block setting the TE values via it's own blockstate.. I think I understand what you are saying but I seem to be having a hard time getting the TE to set the block state.. Strange thing is I get it to update the render as though the block state is changing but when I activate the block after the TE does it's count down (and deactivates the block) the block still thinks it's active..

 

The point of the whole mod is to build a furnace type block. Mostly doing it so I can learn the modding concepts.. Eventually there will be a lot more cooking logic built into the furnace's TE..

 

So I seem to be stuck now on getting the TE to set the ACTIVE property of the block... Am I doing that correctly??

Link to comment
Share on other sites

On 4/27/2017 at 5:48 PM, Draco18s said:

b) you need to override getActualState in order to get the state property from TE data.

And sync the data to the client, of course.

Edited by Draco18s

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

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.