Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd correct implementation of crops #4802
Conversation
@tigerw |
This commit revert commit "Add correct implementation of crops" (1689ecd) as said bearbin (#4802 (comment))
…bone meal This fix will prevent the creation of a melon / pumpkin block when you right-click with a bone meal on a melon / pumpkin plant - It just detect if the plant is full grown. if yes, the method "Grow" is not called
Done @bearbin |
Idea is good but this code will not actually work correctly. |
@@ -60,18 +85,28 @@ class cBlockStemsHandler: | |||
auto oldMeta = a_Chunk.GetMeta(a_RelPos); | |||
auto meta = oldMeta + a_NumStages; | |||
a_Chunk.SetBlock(a_RelPos, m_BlockType, static_cast<NIBBLETYPE>(std::min(meta, 7))); // Update the stem | |||
if (meta > 7) | |||
if (oldMeta == 7) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0ddlyoko
Aug 10, 2020
Author
I don't really understand what can I do if I don't have to edit this method, here I've tested this method and it works
This comment has been minimized.
This comment has been minimized.
bearbin
Aug 12, 2020
Member
I'll rework this myself and then merge - but can you explain what your reason was for changing this function in the first place?
This comment has been minimized.
This comment has been minimized.
0ddlyoko
Aug 12, 2020
Author
With the old implementation, when you right-click on a melon / pumpkin seed with level = 6, the level of the plant become 7 (full grown) and a melon / pumpkin block appears.
This is because this method checks when level will become > 7.
With this implementation, if old level is before 7 (so 6, 5, ...), no melon / pumpkin block will spawn.
This comment has been minimized.
This comment has been minimized.
0ddlyoko
Aug 12, 2020
Author
Another way is to create a special method when a player / dispenser want to grow melon / pumpkin or add a new parameter to this function, but after some tests it seams this solution works
@@ -118,6 +118,11 @@ class cItemDyeHandler : | |||
{ | |||
// Grow by 2 - 5 stages: | |||
auto numStages = GetRandomProvider().RandInt(2, 5); | |||
// No longer create a melon / pumpkin block when right-clicking on a grown melon / pumpkin seed |
This comment has been minimized.
This comment has been minimized.
bearbin
Aug 9, 2020
Member
We should not do nothing here, we only need to cap the numStages in the call to GrowPlantAt to be min(7-currentGrowth, numStages)
This comment has been minimized.
This comment has been minimized.
0ddlyoko
Aug 12, 2020
Author
This is to prevent creating a melon / pumpkin block when someone right-click on a full grown plant with bone meal.
This prevents also dispenser to do it.
To summarise (please correct any mistakes): our current issue is that bonemeal causes crops both to grow stages, and spawn yummy melon. However, Vanilla doesn't spawn melon when using bonemeal; the crop only advances stages, up to a maximum of 7. In this case, as you said, I think we should define This also has the advantage of not needing to add IsFullyGrown to cWorld (we're trying to reduce cWorld's size) xD So something like: // Plant
cBlockPlantHandler::OnUpdate()
{
if (Grow() == 0)
{
// Growth at max, spawn any fruit (pumpkin, melons):
BearFruit();
}
}
// Stems
cBlockStemsHandler::Grow(const int Stages)
{
const auto Meta = std::min(7, OldMeta + Stages);
SetMeta(Meta);
return Meta - OldMeta;
}
cBlockStemsHandler::BearFruit()
{
// Whatever growProduce contained
} D'you think this will work? |
Tigerw's suggestion seems reasonable, and also has the advantage of being extensible to other new types of fruit that might be added. |
Same for me, I'll implement your solution when I have time |
Hey @0ddlyoko are you currently working on this? If you're busy I could apply the changes and merge. |
@tigerw I've got the fortune stuff implemented in a branch ready to pull after I rebase it on top of your style fixes. |
Hello @tigerw I'm not working on it right now, you can merge if you want or you can apply changes & merge |
Thanks all! |
0ddlyoko commentedAug 2, 2020
•
edited
This Pull Request fix some bugs linked to crops.
Some changes are:
IsFullGrownPlantAt(Vector3i)
in classes cChunk, cChunkMap, cWorldIsFullGrown(cChunk &, Vector3i)
in class cBlockHandlerFutur (tomorrow)