Jump to content

Best practices to have one block check the inv/tile entity of a nearby one


trollworkout

Recommended Posts

I got a block VAT that checks nearby FURNACE and do stuff IF smelting the right items.

 

IF nearby FURNACE smelting Iron ore do X  PER Iron ore smelted.

IF  nearby FURNACE smelting Gold ore do Y PER Gold ore smelted.

 

 

The way I figured it out is to enable random tick and to schedule updates at block placement every 60 ticks which is like 2 sec. So every 2 seconds I'm polling the inventory of nearby Furnaces see if they are doing anything. Note that my system actually works is just runs all the time when the chunk is load even if Furnace is off  doesn't matter it will keep on polling. Works but seems a bit wasteful.

 

Is there any other way say some event fired whenever the furnace finishes smelting something? Or can I tap into it somehow create my own custom event listener for that specific furnace to check if anything is finished smelting?

 

Any thoughts or suggestions?

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

enable random tick

and

to schedule updates at block placement every 60 ticks

 

Random ticks are not scheduled ticks.  Literally.

 

Is there any other way say some event fired whenever the furnace finishes smelting something? Or can I tap into it somehow create my own custom event listener for that specific furnace to check if anything is finished smelting?

 

I mean...you could go look at TileEntityFurnace....

But no, there is not

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

Apparently to enable updateTick which is actually what I use you need to have setRandomTick(true)  . YEAHHHH LOGIC!!! :D

 

Not but seriously. When you set random ticking you enable ticking in general. Otherwise is disabled. So updateTick() function starts working.

 

So atBlockPlaced I schedule an update tick and after that I just use updateTick and ignore randomTick function

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

...no, that's not how that works.  You need to schedule the first tick yourself onBlockPlaced.

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

Yeah that's what I did!  I schedule the first one 60 ticks then at the end up tickUpdate i schedule it again :)

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

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.