mojira.dev
MC-123040

Melon seeds and pumpkin seeds do not pop off when in the dark

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

Attachments

Comments 17

Can I request ownership?

Can confirm in 20w48a.

7 more comments

Can confirm in 1.18.2.

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);
}

Can confirm in 1.19 and 22w24a.

Can confirm in 1.19.2.

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. 🙂

[media]

[Mod] redstonehelper

(Unassigned)

Confirmed

Block states

melon_stem, pumpkin_stem

Minecraft 1.12.2, Minecraft 17w49b, Minecraft 1.13.1, Minecraft 19w11a, 1.15.2, ..., 1.19.3, 1.19.4, 23w14a, 1.20.4, 1.21.4

Retrieved