Jump to content

Recommended Posts

Posted

Hello.

I'd like to have an item spawn from my block when it is consumed by fire.
Failing that, I'd like to be able to replace it with another block.

As far as I can tell, there's no event that's fired when a block is consumed by fire.

Does anyone have any ideas on how I could achieve this?

Thanks

Posted

AFAIK no such event exists.

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

Is this a custom block you want to do this with? Or a vanilla block?

 

Could you maybe detect when the block catches on fire and set the block to a different block state and key off that when the block is destroyed to change the block's drops?

Posted

The block isn't destroyed. When it's "destroyed" the Fire class does this:

 

world.setBlockToAir(pos)

 

Your block does not get notified at all.  There's a special-case handler for TNT.

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

It does. :/ I'm thinking of using ASM to just put in an event call similar to onBlockBreak event that goes to my own event. I feel like its required here and would be the least intrusive..

Posted

I understand that and I will, but I'm not willing to wait for the next version of Forge to make it. Poor way now, proper way when it exists.
Still thinking of and waiting for any other ideas that wouldn't require it though, of course

Posted

"Next version" ha, that's funny.

More like sixteen.

But I had to do that to get the crop growth event I wanted.

  • Like 1

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 (edited)

Couldn't you just register a custom IWorldEventListener in the World.Load event and do your logic in IWorldEventListener#notifyBlockUpdate? The method itself passes 2 block state parameters: the current block state and what the previous block state was. You can check if the old block was your custom block and the new block is fire, which would emulate your block "being consumed by fire". The only instance where this fails is if the block is set to fire by a command, but you could probably get around that by tracking the console/chat log (although that's a bit hacky, not 100% fool proof and not really clean). It's not perfect but probably as close as you can get without an official hook.

 

Edit: Also probably a good idea to only register the listener on the server world.

Edited by TheMasterGabriel
  • Like 1
Posted
My idea now is to log when fire goes from fire to air then wood goes from wood to air after in the block position next to it. (accounting for fire facing)
and if they match, then its a burn.
Posted (edited)
22 minutes ago, Cleverpanda said:

Update: this cant differentiate between just breaking the block or being burnt.

 
 

I'm not sure what you mean. If the new block at that position is fire, and the old block was your custom log, then by vanilla logic your log was burned by fire. Of course, this doesn't account for if modded items replace things with fire (like an axe that replaces a block with fire instead of air). It also doesn't take into account if your log is just destroyed completely, which happens from time to time. (Fires don't necessary have to set other blocks to fire, they can just destroy them.) But as I said, it's not foolproof.

 

A better alternative might be to use Forge's substitution system to replace the vanilla fire block with a custom one. It should be the same in every respect other than the BlockFire#tryCatchFire, which you would need to add your custom block case to.

Edited by TheMasterGabriel
Posted

replacing fire might be better. I could have an interface that defies a fire drop and check if the block uses it. shouldnt break other people fire checking as long as they use instanceof I believe.

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.