Posted March 22, 20178 yr 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
March 22, 20178 yr 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.
March 23, 20178 yr 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?
March 23, 20178 yr 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.
March 23, 20178 yr Author 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..
March 23, 20178 yr Author 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
March 23, 20178 yr "Next version" ha, that's funny. More like sixteen. But I had to do that to get the crop growth event I wanted. 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.
March 23, 20178 yr 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 March 23, 20178 yr by TheMasterGabriel
March 24, 20178 yr Author I dont need to bother with the command check. This looks promising, thanks! I'll give it a go
March 24, 20178 yr Author Update: this cant differentiate between just breaking the block or being burnt.
March 24, 20178 yr Author 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.
March 24, 20178 yr 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 March 24, 20178 yr by TheMasterGabriel
March 24, 20178 yr Author thats the case I was talking about. Otherwise, it would only catch 1/6th of the possible cases
March 24, 20178 yr Author 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.