Blood Magic

Blood Magic

90M Downloads

[1.18] [Bug]: Sigil of the Green Grove is consumed when Forge's `BonemealEvent` returns `ALLOW`

Fuzss opened this issue ยท 1 comments

commented

Issue Description:

Fuzss/universalbonemeal#3

What happens:

My Universal Bone Meal adds new bone meal behavior to a bunch of blocks using Forge's BonemealEvent. This also works with the Sigil of the Green Grove, but the sigil is consumed in the process, which shouldn't happen.

The thing is, I don't shrink the stack size, that's Forge in ForgeEventFactory::onApplyBonemeal after the event returns Event.Result.ALLOW. You specifically call that hook in your code, so that will happen for any mod that returns Event.Result.ALLOW for the event.

A simple fix would be to not call the hook, but instead invoke the event directly, skipping any stack size changes. So this:

int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, blockstate, stack);

should just be replaced with something like this (it's the same code from the Forge hook, just no call to ItemStack::shrink):

        BonemealEvent event = new BonemealEvent(player, worldIn, pos, blockstate, stack);
        if (MinecraftForge.EVENT_BUS.post(event)) return -1;
        if (event.getResult() == Result.ALLOW) return 1;

What you expected to happen:

The sigil should remain in the inventory, the stacksize shouldn't change.

Steps to reproduce:

  1. Make BonemealEvent return Event.Result.ALLOW via BonemealEvent::setResult for any block
  2. Sigil of the Green Grove is consumed (=the item stack is deleted as it's count is shrunk by one)

Affected Versions (Do not use "latest"):

  • BloodMagic: BloodMagic-1.18.2-3.2.6-41.jar
  • Minecraft: 1.18.2
  • Forge: ?
commented

Thanks for digging into this issue. I'll make these adjustments soon!