Minecraftforge: [1.14.4] Discussion about Plant changes

Created on 17 Jan 2019  路  14Comments  路  Source: MinecraftForge/MinecraftForge

As mentioned in #5362 1.13 will be a good time to refactor the plant system that forge currently has in place. Currently, we have EnumPlantType, IPlantable, and IGrowable. These three pieces aren't sufficient to create a proper ecosystem for plants to exist and interact with machines and each other.

To resolve this issue, we need to figure out what it is modders need from a plant system. The most basic change would be to start out with changing IGrowable and IPlantable.

The first change that should be made is EnumPlantType should no longer be an Enum. Additionally, certain extra defaults (if suggested) could be added.

IPlantable should be changed to have additional contexts, specifically ItemStack, maybe EntityPlayer and EnumHand if possible. This would allow for mods that need extra data to determine plant state to use this system.

IGrowable should be renamed to IPlant, and have additional methods for harvesting added to it.
Possible ideas for such methods include boolean isMature(World, BlockPos, IBlockState) and void harvest(NonNullList<ItemStack>, World, BlockPos, IBlockState). This would allow for much easier determination of when and how to harvest a planted object, which is currently impossible.

Currently, the problem is determining the needed contexts for people who make plants, seeds, and harvesters. I'd like anyone who interfaces with plants to state what they would like to see from a redesigned plant system, so that this can be designed and completed before the breaking change window is over.

1.13 Needs Update RFC Stale

Most helpful comment

Okay, potential implementation spec available at: https://gist.github.com/Shadows-of-Fire/9c1699d061754bb97056ec7a0a65b00f
Would like anyone to look over that and see if there's any pieces missing

All 14 comments

Another thing that can be done is add a EnumActionResult plant(World, Pos, ItemStack) to IPlantable, to allow custom placement. This could be helpful for taller plants.

The change to IGrowable -> IPlant looks good as most of the time they are crops (except sapplings). My only requests are isMature and harvest as it will make life much easier by not having to implement a custom handler for every crop every mod has.

Maybe harvest having an extra boolean to replant itself.

Add a check for 'Can view harvest level [type]' I know a few mods do not like there plants to be automated. However, still would like for UI features or NPCs to check the levels. So we could add either a context based input into isMature or a separate method to solve for this case.

I don't recall all that was in the old methods and can't check while at work. What I would like to see:

  • get all the growth state of a plant
  • get the starting state
  • get the end state
  • get the drops of each state
  • get the death state (edge case for mods that wish to poison or destroy crops, default to air)
  • get the seed
  • get a list of supported blocks/materials
  • call to check if canPlant for location
  • check for mature, would be useful to be enum driven [Growing, Harvestable, Complete, Dead] that way we can support more complex crops. Such as blocks that can hit a harvest state for 2 drops but can then grow to a complete growth state for 4 drops. However, can hit a end state of death for no drops. TBH likely can be handled by other logic then a plant interface.
  • check for progress [0.0-1.0]

The first change that should be made is EnumPlantType should no longer be an Enum. Additionally, certain extra defaults (if suggested) could be added.

While we are on this, I wonder if there is possibility that we can go ahead and deprecate EnumPlantType on 1.12 branch first, and introduce a new interface as well?

Does anyone think that the classes BlockBush, BlockCactus, and BlockReed should continue to implement IPlantable? It seems like it should be used for Item classes, but I don't know if others expect blocks to implement it.

In my opinion, blocks shouldn't implement it because the item is planted and the block is placed. However, a second "plant" interface could be useful for blocks so mods know what has been planted earlier and what is a plant or not.

blocks need an interface for checking if it can continue growing. items need the interface to see if it can be planted.

just interjecting to say that if we're going to be adding "dumb marker" interfaces that just exist to say "i am a plant", those kinds of cases are better served by using tags (see minecraft:bamboo_plantable_on and minecraft:small_flowers tags in 1.14, for example)

those kinds of cases are better served by using tags

So like, replace EnumPlantType with a special tag? If that would be possible, I am for it.

Currently my implementation has IPlant which is a superinterface of IGrowablePlant and IHarvestablePlant. These will then provide the methods that allow modders to grow/force grow/harvest/replant all types of plants.

Anyone who is following this, there's an implementation available at #5398

Okay, potential implementation spec available at: https://gist.github.com/Shadows-of-Fire/9c1699d061754bb97056ec7a0a65b00f
Would like anyone to look over that and see if there's any pieces missing

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!

This issue has been automatically closed because it has not had activity in a long time. Please feel free to reopen it or create a new issue.

Was this page helpful?
0 / 5 - 0 ratings