AppleCore

AppleCore

56M Downloads

Add bonemeal growth event

squeek502 opened this issue ยท 4 comments

commented

From @Dynious in #12:

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.

commented

Awesome :D

commented

@Dynious, let me know what you think of the implementation in c7eae6d. It's not quite finished, but I'd like some feedback.

There are a few things I'm unsure about:

FertilizationEvent.CanFertilize

The FertilizationEvent.CanFertilize event is basically redundant given how bonemeal uses IGrowable.func_149852_a:

if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_))
{
    igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_);
}

--p_150919_0_.stackSize;

If func_149852_a returns false, bonemeal still gets used (stackSize decremented); it just doesn't call the fertilize method. So, I could remove the CanFertilize event and just make the Fertilize event's result serve the same purpose (which it already could).

Non-IGrowable growables

As with everything AppleCore seems to deal with, IGrowable is not universally used by mods for growable things. For example, HarvestCraft uses a BonemealEvent handler, checks instanceof BlockPamFruit/BlockPamSapling, and calls specific member methods that do the fertilization. This isn't a huge deal, as I can apply the same ASM to those specific member methods easily, but just be aware that not everything uses IGrowable.

Actually, in writing this, I realize that the events' IGrowable fields aren't going to work. Ugh.

commented

It looks like a solid system, but I do agree CanFertilize is redundant and can be confusing. I'd say removing it is the better option.

About non-IGrowables, I'm not too bothered with that (I'm gonna disable bonemealing anyways), but this might be useful in cases where you'd want to track all fertilization (and not just disable it).

I'm gonna use these events to (partially) disable all accelerated plant growth, and IGrowable is one of the ways mod accelerate plant growth.

Thanks for this! If you need any help just contact me!

commented

Almost there. Just need to hook into the various non-IGrowable mod fertilization implementations that I'm aware of and then I'll merge to master.