Conversation
| } | ||
|
|
||
| cir.setReturnValue(EVENT_DISPATCHER.postCropDrops(rng, level, pos, pot, crop, newItems)); | ||
| cir.cancel(); |
There was a problem hiding this comment.
setReturnValue already does the cancel
Is it needed to kind of overwrite the method with an inject & cancel?
The original one doesn't have much logic but it might still be better to do a @ModifyArg for the crop items?
And then go through the items and apply the quality directly, something like:
@ModifyArg(method = "generateDrop", at = @At(value = "INVOKE", target = "Lnet/darkhax/botanypots/events/BotanyPotEventDispatcher;postCropDrops(Ljava/util/Random;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/darkhax/botanypots/block/BlockEntityBotanyPot;Lnet/darkhax/botanypots/data/recipes/crop/Crop;Ljava/util/List;)Ljava/util/List;"))
private static List<ItemStack> quality_food$applyQuality(final List<ItemStack> items, @Local(argsOnly = true) final BlockEntityBotanyPot pot) {
ItemStack crop = pot.getInventory().getCropStack();
ItemStack soil = pot.getInventory().getSoilStack();
for (ItemStack item : items) {
QualityUtils.applyQuality(item, crop, soil);
}
return items;
}(applyQuality does not create a new ItemStack, it modifies the existing one)
There was a problem hiding this comment.
Actually - since they use events, can't that be used?
By listening to the CropDropEvent event?
Could either be highest priority (to immediately apply quality) or lowest (to make sure any added (relevant) loot also has their quality adjusted)
There was a problem hiding this comment.
yeah, it is an event, however it's a way of using events that I'm unfamiliar with, so I'm not sure. If you look at the code
BotanyPotEventDispatcherForge#75, while the event is indeed posted, it's basically created with the originalDrops and then the event's drops are taken, which I think are just the originalDrops
I can try checking how the Botany Pots tiers mod does it, since that mod also changes drops, altough in a slightly different way since it inherits the BE
| continue; | ||
| } | ||
|
|
||
| double chance = QualityConfig.getChance(quality); |
There was a problem hiding this comment.
Does the crop / seed in the pot not retain quality?
If it does then
chance = QualityConfig.calculateChance(quality, QualityConfig.getWeight(blockQuality));could be used instead (see applyQuality for block drops)
blockQuality would be the item quality of the crop / seed in this case
This would allow quality crops to be more likely to drop (higher) quality loot
Would just have to be careful (as in check, whether the crop is actually fully grown or not), otherwise you'd be able to reroll the quality of the seed into higher tiers (that might actually be the case with the current compatibility logic)
There was a problem hiding this comment.
the logic itself only runs when the items would be dropped which equals the crop being fully grown
from what I could see by debugging the item gotten with pot.getInventory().getCropStack() does keep the quality
I pushed a commit that should implement the changes, lmk if I missed something
Hi,
I was messing around with the mod and noticed that botany pots did not have compat, so I took it upon myself to make it
Now both normal and hopping botany pots roll correctly for all results, while also applying the farmland bonus when applicable
Botany Pots addons should also work if they inherit from the original classes
Let me know if there are changes needed, and if you want me to add the compat to previous versions as well
Cheers,
Leo