-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace PlantType system with SpecialPlantable interface and canSustainPlant block method #971
Replace PlantType system with SpecialPlantable interface and canSustainPlant block method #971
Conversation
Closes neoforged#703 Also fixed several spots in NeoForge where we were passing bad arguments as well. Note: the track command's crash from bad argument passed to Translatable will be fixed in this PR: neoforged#915
Last commit published: 0a7b1d1bb2e685443705713488c639a62eecf767. PR PublishingThe artifacts published by this PR:
Repository DeclarationIn order to use the artifacts published by the PR, add the following repository to your buildscript: repositories {
maven {
name 'Maven for PR #971' // https://github.com/neoforged/NeoForge/pull/971
url 'https://prmaven.neoforged.net/NeoForge/pr971'
content {
includeModule('net.neoforged', 'neoforge')
includeModule('net.neoforged', 'testframework')
}
}
} MDK installationIn order to setup a MDK using the latest PR version, run the following commands in a terminal. mkdir NeoForge-pr971
cd NeoForge-pr971
curl -L https://prmaven.neoforged.net/NeoForge/pr971/net/neoforged/neoforge/21.0.111-beta-pr-971-PlantTypeRefactor/mdk-pr971.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip To test a production environment, you can download the installer from here. |
@TelepathicGrunt |
@TelepathicGrunt |
src/main/java/net/neoforged/neoforge/common/SpecialPlantable.java
Outdated
Show resolved
Hide resolved
patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch
Outdated
Show resolved
Hide resolved
patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch
Outdated
Show resolved
Hide resolved
patches/net/minecraft/world/level/block/SmallDripleafBlock.java.patch
Outdated
Show resolved
Hide resolved
BasePlantable sounds like it is for vanilla plantable items too. But the interface is better suited for special plantable blocks that aren't simple vanilla villager plantable tagged BlockItems. (And that we can't patch vanilla items to have the interface as they are using the BlockItem class directly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still like a second pair of eyes on this
patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch
Outdated
Show resolved
Hide resolved
@TelepathicGrunt, this PR introduces breaking changes. Compatibility checks
|
…t/NeoForge into PlantTypeRefactor
…inPlant block method (neoforged#971) Co-authored-by: Dennis C <[email protected]>
It is well known the old PlantType system used in past is quite clunky and broken in many areas. It does not even cover some important vanilla plants such as Cocoa.
Basically, it tried to be many things at once and failed at all of them. It tried to allow for blocks to define what plant it can keep as well as control what modded crops villagers can place.
This PR splits the two goals into separate systems.
SpecialPlantable interface (any suggestions of different name?)
IPlantable
interface and instead of being on blocks, you would put the SpecialPlantable interface on your own custom item classes.canPlacePlantAtPosition
andspawnPlantAtPosition
methods.villagerCanPlantItem
is optional to override.villagerCanPlantItem
to return true, Villagers can pick up this item and put it into the Villager's inventory. Then the Villager will now be able to plant this item on nearby block that extend FarmBlock!Changed canSustainPlant to return a Tristate and patched it into more blocks
canSustainPlant
and return TRUE, FALSE, or DEFAULT enum. If DEFAULT, the plant block will continue to run it's normal logic for checking survivability. If TRUE or FALSE is returned, it will override the plant's survivability checks to what the soil block wants.canSurvive
method should callcanSustainPlant
on the block the plant is attaching to and respect the enum result that comes out. Basically, modded plants will have to "opt-in" into this system. If the pklant overridesmayPlace
method, they will still respectcanSustainPlant
because the patches tries to target thecanSurvive
methods where-ever it makes sensecanSustainPlant
are in places where vanilla is doing block type checks or light checks. Any check for block shape was ignored to keep patch size down and because those kinds of plants technically support any block as long as the block's shape is good for supporting the plant.CropBlock
'sgetGrowthSpeed
method had its first parameter changed fromBlock
toBlockState
in order to pass in the correct crop block's blockstate tocanSustainPlant
. No idea why mojang passed only the Block in but this is an annoying breaking change to a vanilla method param type I ended up doing. Any suggestions around this?Added GameTests for all kinds of plants
Added
neoforge:villager_farmlands
block tagFeed back welcomed as there's a lot of improvements that can be done to this PR.