Add old & new metadata value to growth event(s)
Dynious opened this issue ยท 4 comments
I'd be awesome if you could add the old & new metadata values to growth event(s). The old metadata value is not always the current value minus 1 (see for example BlockCocao). Adding the new value will just save a tiny bit of overhead by not having to get it again.
Mainly needed in GrowthTick, but adding the current and new value in AllowGrowthTick might help some other users of the api too :)
Thanks!
Good idea. I remember considering this when initially writing it but I think I didn't do it because HO didn't need it. I'll have to figure out the best way to add it while maintaining backwards compatibility.
Also, as AppleCore tracks plant growth, it might also be logical if it has an BonemealGrowth (not a good name as not only bonemeal causes growth) event as well. An AllowBonemealGrowth event kinda exists already in Forge, but it only tracks bonemeal used by players, so that isn't really useful to control pant growth. Plants implement IGrowth to use this bonemeal growth functionality.
I need these hooks for a new mod and I could easily add these hooks myself, but as AppleCore already has a list of plants and seems to be kind of a standard for this it seems to me that it would be better to add it to AppleCore.
Adding the incremented metadata to AllowGrowthTick would be a giant pain to do cleanly, so I don't think I'm going to do that.
For GrowthTick, I'm just going to add previousMetadata, because getting the incremented metadata would be a pain without simply calling world.getBlockMetadata when firing the GrowthTick event (for example, the incremented metadata is buried within the setBlockMetadataWithNotify call for Cocoa).
Out of curiosity, what's your new mod going to be doing?
That's just fine, I only need the old value, the rest I can either get another way or don't really need. Thanks!
The mod is about bio-/ecosystems. Chunks have nutrients that plants need to grow. Too little nutrients and plants will die. A bunch of formulas/algorithms of how chunks interact with each other, bacteria and plants. It will be as close to reality as is possible and fun, so it might also be educative! Main goal is to make the Minecraft world feel more alive and less static.