Skip to content

Botany Pots compat - 1.20.1 - #60

Open
MtcLuna05 wants to merge 2 commits into
SiverDX:1.20.1from
MtcLuna05:1.20.1
Open

MtcLuna05 wants to merge 2 commits into
SiverDX:1.20.1from
MtcLuna05:1.20.1

Conversation

@MtcLuna05

@MtcLuna05 MtcLuna05 commented Jul 13, 2025

Copy link
Copy Markdown

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

@MtcLuna05
MtcLuna05 changed the base branch from 1.21 to 1.20.1 July 13, 2025 07:53
}

cir.setReturnValue(EVENT_DISPATCHER.postCropDrops(rng, level, pos, pot, crop, newItems));
cir.cancel();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@MtcLuna05 MtcLuna05 Jul 13, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants