Pam's HarvestCraft 2 - Trees

Pam's HarvestCraft 2 - Trees

15M Downloads

When fruits grow from randomTick, they don't trigger the BlockEvent.CropGrowEvent

Darkorg69 opened this issue ยท 0 comments

commented

In : https://github.com/MatrexsVigil/phc2trees/blob/1.18.2/src/main/java/com/pam/pamhc2trees/blocks/BlockPamFruit.java
Line 53, Method randomTick, when the FruitBlock grows it doesn't call CropGrowEvent.
All vannila crops call this event and other mods which add functionality to some crops rely on this event.
Currently it produces a problem with Serene Seasons mod.
When you add a DataPack for any fruit block, regardless of the season the fruit will continue to grow as Serene Seasons also depends on this event.
How to fix this? Just call the event in the method randomTick, take a look at how this is handled in Minecraft CropBlock class

    public void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Random pRandom) {
        if (!pLevel.isAreaLoaded(pPos, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light
        if (pLevel.getRawBrightness(pPos, 0) >= 9) {
            int i = this.getAge(pState);
            if (i < this.getMaxAge()) {
                float f = getGrowthSpeed(this, pLevel, pPos);
                if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(pLevel, pPos, pState, pRandom.nextInt((int)(25.0F / f) + 1) == 0)) {
                    pLevel.setBlock(pPos, this.getStateForAge(i + 1), 2);
                    net.minecraftforge.common.ForgeHooks.onCropsGrowPost(pLevel, pPos, pState);
                }
            }
        }
    }