-
Notifications
You must be signed in to change notification settings - Fork 20
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
Bonemeal API #78
Bonemeal API #78
Conversation
} | ||
|
||
static { | ||
addPlant(BlockBase.GRASS.getDefaultState(), new GrassStructure(), 1); |
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.
Doesn't this replace the vanilla generation?
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.
Yes, it replaces vanilla generator since calling API cancels vanilla code
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.
Flowers no longer generate because of this
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.
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.
Don't really understand why only grass generator is replaced out of all bonemeal generators
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.
If you will not override it then:
- If event is not cancellable custom plant will generate with too hight density and override vanilla grass. If its generation chance will be forced to be low it will be not possible to generate hight density plants
- If event is cancellable then adding custom plant will stop any grass from spawning
Basically adding these generators just makes things simple - you get a complete control over custom plant density together with grass, and it will generate patches almost identical to vanilla
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.
When you say "it will generate patches almost identical to vanilla", do you mean with custom plants or without?
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.
Both, by default it will generate vanilla grass and flowers in vanilla way, but you can add more flowers/grasses (or even structures) to generation pool, and they can have weight even larger than vanilla grass
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'm kind of hesitant of overriding vanilla generation like this. Though, to be fair, the original code does use ItemBase#rand
which uses a different seed each run, so it probably won't affect anything.
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.
That produces a result equal to vanilla code. It is possible to use more injects into vanilla code, but there will be no difference except worse performance and troubles for mods to mixin above that
# Conflicts: # station-items-v0/src/main/java/net/modificationstation/stationapi/api/bonemeal/BonemealAPI.java
I added a small fix for missing Overworld biomes, it is a small fix so I didn't open another PR for it |
|
||
public static void addPlant(TagKey<BlockBase> ground, Structure plant, int weight) { | ||
BlockRegistry.INSTANCE.forEach(blockBase -> | ||
blockBase.getStateManager().getStates().stream().filter(state -> state.isIn(ground)).forEach(state -> addPlant(state, plant, weight)) |
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.
Caching states from tags like this is probably not a very good idea, tags are reloadable after all.
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.
Well, original idea was to add plants to all blocks with tag, like "nether_ground" or similar things. I can adapt code to work with additional internal tag storage, that can solve this issue
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.
Done, now it should support both reloadable tags and states
Simple API to add more blocks into bonemeal actions.
Blocks can override
onBonemealUse
method to change their state when bonemeal was performed on them (in test mod obsidian will turn into log block).Plants/Structures can be added into
BonemealAPI
to be generated on specified terrain. In test mod you can use bonemeal on sand to grow bookshelves.PR is ready for review