Jump to content

Updating Block Renderer (TE properties) after inventory change


Recommended Posts

Posted

Basically if I call

sendUpdates()

(see below) every so often, I can be reasonably assured that the renderer will update, just not instantly.

 

e.g. I can create a timing variable and call the method every 100 ticks and that results in the model changing within 5 seconds of when it should.

 

	private void sendUpdates() {
	markDirty();
	worldObj.markBlockRangeForRenderUpdate(pos, pos);
	worldObj.notifyBlockUpdate(pos, getState(), getState(), 3);
}

 

If I call this method both after any time the TE changes its own contents (i.e. "smelting" an item into another item or consuming "fuel") and not every few seconds, then it also seems to work and pretty much instantly.

 

However, when inserting items via a hopper the update is not always applied.  That is, for inserts from the sides into the input slot, the update is instant.  When inserting from the top (for fuel) the update never occurs (unless the fuel is consumed, which also sends an update, and that one works).

 

If I try to delay all updates by 1 tick (so that all methods that would send a synchronization packet merely flip a boolean and then at the end of onUpdate if that boolean is true, call sendUpdates() and set the bool to false), then I still get the same behavior: inserting from the sides updates instantly (1 tick delay) inserting from the top never updates (and in fact, fuel consumption doesn't update this time either).

 

I don't get it.

 

http://pastebin.com/PKMvsdJu

rack.png

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

You may want to store a reference to the

TileEntity

in

ItemLeatherHandler

and override

ItemStackHandler#onContentsChanged

to trigger the update packet.

 

I'm not entirely sure why your current code isn't working properly.

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.

Posted

You may want to store a reference to the

TileEntity

in

ItemLeatherHandler

and override

ItemStackHandler#onContentsChanged

to trigger the update packet.

 

Its the salt that's not working correctly, but I'll give that a shot.

 

Faux Edit:

Nope, that doesn't help either. :\

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.

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.