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
[B+C] Add a way to induce mob breeding, adds BUKKIT-5687 #1085
base: master
Are you sure you want to change the base?
Conversation
Adds a system to induce mob breeding through the Bukkit API.
When I look at the javadoc, it explains nothing. Breeding is stateful, and it is more than binary.
This is an empty husk of an APi, relying on an in-depth knowledge of what the respective obfuscated method does. TL;DR: No one can use this but you. Edit: Oh, the ticket needs to describe these kinds of things too - as it is, it's too ambiguous to use. |
@Wolvereness - How does this explanation sound: |
/edit:
|
@Wolvereness I added answers to everything to the javadocs. |
@ Anyone - is there anything more I can adjust here? Anything keeping it from being pullable? Or....? |
The javadocs are not wrapped correctly (78 characters per line, then hit enter, provided words don't get cut off weirdly). As well the javadocs explain what breeding is in kind of a wrong sense. In Minecraft an animal is not "born", it is "spawned due to animal attraction". As well the javadocs contain a lot of scenarios that don't need to be there (such as use cases for the Player argument). Here are some questions I have thus far:
For now though, that is all I have to comment on. //edit:// Another question:
|
@turt2live I thought the rules were no-80-char-cutoffs. Fixed. The timeout could be changed... it requires pulling a file from mc-dev and adding functions... but that I can do. |
The 80 column limit applies to only code. JavaDocs are not code, they are documentation. I understand that the player reference is used to reward the player, however I'm asking if it's possible to support no player being defined for some potential cases. I also understand it's an automatic process, but again I'm asking if it's possible to skip the middle stage for the purposes of a method like I think that adding a variable timeout could be useful as well, but I'm unsure of what people who would actually use this new API would think about it. Looks like some community involvement is needed ;) |
@turt2live |
Maybe add another method without the player argument
|
@iKeirNez There... is one. |
Doesn't look like it... |
Or did you want one with timeout but no player? |
A timeout method without the player argument would be more consistent.
|
@iKeirNez Added |
Wait. Is this Minecraft plugin or Bukkit.jar for eclipse plugin development? |
This is a request to add code to the Bukkit project. If it gets added, it will be included in the Bukkit.jar so that other developers may use the code added in their plugins. |
It might be useful to have an event for breeding, so that plugins would have a way to get notified/cancel it when it happens through the API (instead of through a |
@Aaron1011 That sounds like a separate PR as I think there should be an event for that anyway (API induced or not) |
@iKeirNez I would disagree. It makes more sense to push a breeding API in one piece over pushing it in multiple. |
@turt2live: That was my reasoning as well. I've seen other merged PRs that added in an API along with the corresponding event. |
A way to directly induce baby-spawning
You may want to review #791 while working on this as well. |
@turt2live I've added the difference I saw - experience get/set functions. |
this.entityTwo = entityTwo; | ||
this.breeder = breeder; | ||
this.baby = baby; | ||
this.XP = XP; |
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.
As per java conventions. This should be xp
in lowercase.
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.
Will fix.
There's at least 2 other events that have been in bleeding, that look and feel more productive than the event you provide: (At least, I thought there were 2...) This is, of course, an old commit. So it's missing xp handling. I'd have to look at your implementation for "breeder" though before I can comment on it. https://github.com/Bukkit/Bukkit-Bleeding/compare/feildmaster/BreedingAPI |
@feildmaster What is my event missing that the others provide? |
@mcmonkey4eva Yours is missing |
@mcmonkey4eva A couple of issues I ran into while testing:
There may be more issues, but those are the ones I found right away. Please provide proper testing materials and fully test your PR please. |
getParents added |
|
So either way it's broken... I've tested that entering |
|
I don't think it should do that then. If a plugin wants an animal to be ready for breeding, it should be able to do so with this one method call. Modifying the age isn't really a decent solution. |
Fair enough, I'll make it force breedability |
* | ||
* @param animal the animal to breed with. | ||
*/ | ||
public Ageable breedWith(Animals animal); |
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.
Why is this an Ageable?
Can an Animal spawn a non-animal?
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.
Ask Mojang. The internals use Ageables for the child entities. It might be something set up for modding/future edits where animals can spawn non-animals.
1- The baby should be the main entity, this event is about the baby. The parents/how it got created are secondary. 2- Instead of providing "breeder" to the constructor of the event, you should rather add a getBreeder in the Animal api. After that use the api to store an internal value that the event can't edit for a set state. I'm unsure of a set, because of how you worked your setBreeding methods. 3- Allowing the breeder to be modified in the event shouldn't happen. Events should be considered "read or cancel" except for special data like xp. If they want to change the breeder they're able to do so after canceling the event and calling their new event 4- After reading your implementation on breedWith... I don't like it. There's no reason to have it. |
@feildmaster - all 4 done. |
The Issue:
There is not a way to induce mob breeding, or check whether they are trying to breed.
An animal is considered to be breeding when it has been given food (EG: wheat) and is looking for another animal of its species to mate with and produce a baby animal.
Justification for this PR:
This new API feature will be useful for any plugin that wishes to induce mob breeding. An example case would be an NPC Farmer - without a way to make mobs breed, it would have to be faked with workarounds, EG manually spawning heart particles and manually spawning baby entities.
PR Breakdown:
Bukkit-side:
Adds the functions in
Animals
to induce breeding / check breeding attempt.CraftBukkit-side:
Implements the functions in
CraftAnimals
to induce breeding / check breeding attempt. Mostly just wrapping some NMS functions.Testing Results and Materials:
Any default plugin or pre-existing plugin can simply run the functions and output results.
I personally tested by inducing two cows to breed and observing their
isBreeding
state throughout the process.Quick example code would be a command that executes:
Relevant PR(s):
CraftBukkit: Bukkit/CraftBukkit#1400
JIRA Ticket:
BUKKIT-5687 - https://bukkit.atlassian.net/browse/BUKKIT-5687