The bug
Like wheat seeds, potatoes and the other crops, melon and pumpkin seeds require light to grow. However, unlike seeds, potatoes and the other crops, melon and pumpkin seeds do not pop off in the dark and can be placed in the dark. This is inconsistent.
Code analysis
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 1
Attachments
Comments 17
Can confirm in 22w18a. Here's a code analysis of this issue along with a fix.
Code Analysis:
The following is based on a decompiled version of Minecraft 1.19.2 using MCP-Reborn.
Blocks within the CropBlock.java
class such as wheat, carrot, potatoes, etc... contain the canSurvive()
boolean within their code that determines whether they can survive or not based on the light level of their location or if the said location has access to the sky. This boolean restricts the placement/existence of crop blocks if the light level is less than or equal to a value of 7. The problem here is that this boolean isn't present anywhere within the StemBlock.java
class ultimately allowing stem blocks to exist in low light levels.
Fix:
Simply allowing stem blocks to override the canSurvive()
method located within the BushBlock.java
class to make it so that they cannot be placed or exist within low light levels will resolve this problem. The following lines of code can be added somewhere within the StemBlock.java
class to fix this issue.
Fixed Code:
public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) {
return (levelReader.getRawBrightness(blockPos, 0) >= 8 || levelReader.canSeeSky(blockPos)) && super.canSurvive(blockState, levelReader, blockPos);
}
Following on from my code analysis, I've double-checked my proposed fix and I can confidently confirm that it's fully functioning and works as expected, so I've attached a screenshot to this report that shows the method that needs to be added somewhere within the StemBlock.java
class to fix this issue. I feel this information may be quite insightful hence my reasoning for providing it. 🙂
Can I request ownership?