NeoForge icon indicating copy to clipboard operation
NeoForge copied to clipboard

Add easy way to get growing block with CropGrowEvent from GrowingPlantHeadBlock

Open khjxiaogu opened this issue 1 year ago • 0 comments

CropGrowEvent usually have a blockstate for growing block, however, it's impossible to get growing block from GrowingPlantHeadBlock as it calls event by:

net.neoforged.neoforge.common.CommonHooks.onCropsGrowPre(pLevel, pPos.relative(this.growthDirection), pLevel.getBlockState(pPos.relative(this.growthDirection)), pRandom.nextDouble() < this.growPerTickProbability)

Unlike other plants, this code would only provide the blockstate that the plant are growing into but not the original growing plant. There should be a way to get growing block from the event.
Possible fixes:

  1. change this code into
net.neoforged.neoforge.common.CommonHooks.onCropsGrowPre(pLevel, pPos.relative(this.growthDirection), state, pRandom.nextDouble() < this.growPerTickProbability)
  1. modify CropGrowEvent and add a blockstate for the origin block.

khjxiaogu avatar Feb 03 '24 16:02 khjxiaogu