Conversation
See title. Still a lot to do though. For now, they're exactly identical aside from the "when does it autoeat", though while testing I noticed they're both 10 levels to apply when autoeat probably shouldn't be 10 levels. More importantly, though, the next commit will likely be about letting me make some Enchant's exclusive to other Enchant's. I'll need it anyway to make Haachama's enchant exclusive to Space Bread.
That doesn't mean they have to, but they can be. I looked everywhere where Enchant.exclusive is used (thanks, IntelliJ). I rewrote Utility.java's usage accordingly, and put comments in Events.java's 4 usages explaining why I didn't touch them. I have not tested this code; the "test plan" for this is to try to put multiple AutoEat enchantments onto one helmet.
Not implemented yet; I stopped because I realized maybe I should write that in Utility incase we want any other items to recursively search for an item in your inventory.
Yes, I had this code all done when I did the last commit. I just told GH desktop to not commit the last thing in the same commit, so you can look at the code for this one separately.
Hmm... This Utility.recursiveSearchForItem function may need some reworking, though. I can change the ItemStack just fine but it doesn't update in the BlockMetaData.
I put an implNote that says what I think about this implementation.
I might need this later for recipes, or maybe it'll be deleted as better recipes are requested.
This will probably end up changed later, but whatever.
That took a bit longer than I expected.
REMINDER TO SELF: If you ever, *ever* need to Fix Recipes again, make sure the HoloItem ingredients are in Events.ingredients.
Only one form of AutoEat, which - since it's going on Okayu - I guess I'll name it MoguMogu. This code doesn't work, but I at least fixed the recipes. Now to fix the rest of the stuff...
Yes, I did just copy Enchant.java from upstream here. Hopefully that fixes the merge conflicts?
Successfully merge upstream commit.
Remove lingering instances of old AutoEats
Since we're just using MoguMogu now.
| * Nutrition values from eating certain foods. | ||
| * Note: Chorus fruit and cake aren't listed here. | ||
| */ | ||
| public static final Map<Material, float[]> nutritionValues = new HashMap<>(){{ |
There was a problem hiding this comment.
It's possible to get these values from the server internals by using reflection.
Relevant packages are:
net.minecraft.world.food
net.minecraft.world.item
We would want to access the foodProperties field of each Item.
The way to not hardcode this would be to iterate all materials, filtering for the ones that are edible and not legacy -> create a bukkit ItemStack for each -> convert to nms ItemStack -> ItemStack::getItem -> Item::getFoodProperties -> then the food properties instance has a bunch of getters for stuff.
There was a problem hiding this comment.
"Convert to nms ItemStack" Ah, I was avoiding using NMS because I wasn't sure if we were allowed to have it, but since we are, this doesn't have to be hardcoded... might even be able to remove the variable entirely.
Reminder to self: Confirm what happens if you AutoEat Chorus Fruit.
There was a problem hiding this comment.
We'd better move the Class and Method reflection stuff out to a new class so it'll be more maintainable and not such a mess. For iterating the Materials, it's gonna be:
for (final Material material : Material.values()) {
if (material.isEdible() && !material.isLegacy()) {
... // do the food property getting stuff and insert the values into the map
}
}nutritionValues is still hard-coded though and I don't know how to fix that. The instructions I was given were "convert to NMS ItemStack" and I don't know how.
Still not done, but it's progress. Feels like black magic.
Note: This will eat chorus fruit but not teleport.
[BROKEN] This code is broken, but I'm uploading it so Termi can take a peek and see if I've missed something or if we'll come to the same conclusion
| public MoguMogu(){ | ||
| super(name, material, lore, durability, shiny, cost, acceptedIds, acceptedTypes, expCost); | ||
|
|
||
| // Incase I make an error like use BEETROOTS (block) insteaad of BEETROOT (item) |
There was a problem hiding this comment.
Could be made into a junit test instead
There was a problem hiding this comment.
On second thought, it'll be pointless after we make it not hardcoded.
This is a separate commit to the next one incase I want to undo the next commit but keep the black magic that I've written here.
Unfortunately now the hunger and saturation aren't increasing, for some reason.
I didn't do the nutritionValues changes because I figured we wouldn't need it if I got finishUsingItem to work correctly. On that note, finishUsingItem should have been fixed the past ... many commits
Added an enchantment for okayu.
I'd go into more detail but I'd also like to sleep.
Finished implementation (only thing missing was for mods to change/approve recipe) on 2/22, so that's a :meow: in my books.