Search in sources :

Example 1 with CropInfo

use of net.darkhax.botanypots.crop.CropInfo in project AgriCraft by AgriCraft.

the class BotanyPotsHandler method onLookUp.

// Stats and seed conversion
@SubscribeEvent
@SuppressWarnings("unused")
public void onLookUp(LookupEvent.Crop event) {
    if (event.getCurrentLookup() instanceof AgriCropInfo) {
        event.setLookup(((AgriCropInfo) event.getCurrentLookup()).withStats(event.getItemStack()));
    } else {
        if (!AgriCraft.instance.getConfig().overrideVanillaFarming()) {
            return;
        }
        if (VanillaSeedConversionHandler.getInstance().isException(event.getItemStack())) {
            return;
        }
        AgriApi.getGenomeAdapterizer().valueOf(event.getItemStack()).ifPresent(genome -> {
            ItemStack seedStack = genome.toSeedStack();
            CropInfo info = BotanyPotHelper.getCropForItem(seedStack);
            if (info instanceof AgriCropInfo) {
                event.setLookup(((AgriCropInfo) info).withStats(seedStack));
                AgriCraft.instance.queueTask(() -> event.getBotanyPot().setCrop(info, seedStack));
            }
        });
    }
}
Also used : CropInfo(net.darkhax.botanypots.crop.CropInfo) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

CropInfo (net.darkhax.botanypots.crop.CropInfo)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1