Quality Food

Quality Food

56.1k Downloads

[Support] MineColonies

Awenlice opened this issue ยท 0 comments

commented

Can the crops that the farmers in the simulated colony can destroy have good quality?
I have found the corresponding code, but I am unable to apply the mixin correctly.

package com.minecolonies.core.entity.ai.workers;

protected final boolean mineBlock(@NotNull BlockPos blockToMine, @Nullable BlockPos safeStand, boolean damageTool, boolean getDrops, Runnable blockBreakAction) {
    BlockState curBlockState = this.world.getBlockState(blockToMine);
    Block curBlock = curBlockState.getBlock();
    if (!(curBlock instanceof AirBlock) && !(curBlock instanceof IBuilderUndestroyable) && curBlock != Blocks.BEDROCK) {
        if (this.checkMiningLocation(blockToMine, safeStand)) {
            return false;
        } else {
            ItemStack tool = this.worker.getMainHandItem();
            if (getDrops) {
                int fortune = ItemStackUtils.getFortuneOf(tool);
                List<ItemStack> localItems = new ArrayList();
                if (!tool.isEmpty() && this.shouldSilkTouchBlock(curBlockState)) {
                    ItemStack fakeTool = tool.copy();
                    fakeTool.enchant(Enchantments.SILK_TOUCH, 1);
                    localItems.addAll(BlockPosUtil.getBlockDrops(this.world, blockToMine, fortune, fakeTool, this.worker));
                } else {
                    localItems.addAll(BlockPosUtil.getBlockDrops(this.world, blockToMine, fortune, tool, this.worker));
                }

                localItems = this.increaseBlockDrops(localItems);

                for(ItemStack item : localItems) {
                    InventoryUtils.transferItemStackIntoNextBestSlotInItemHandler(item, this.worker.getInventoryCitizen());
                }

                this.onBlockDropReception(localItems);
            }

            this.triggerMinedBlock(blockToMine, curBlockState);
            if (blockBreakAction == null) {
                CitizenItemUtils.breakBlockWithToolInHand(this.worker, blockToMine);
            } else {
                blockBreakAction.run();
            }

            if (tool != ItemStack.EMPTY && damageTool) {
                tool.getItem().inventoryTick(tool, this.world, this.worker, this.worker.getCitizenInventoryHandler().findFirstSlotInInventoryWith(tool.getItem()), true);
            }

            this.worker.getCitizenExperienceHandler().addExperience(0.05);
            this.incrementActionsDone();
            return true;
        }
    } else {
        if (!curBlockState.getFluidState().isEmpty()) {
            this.world.removeBlock(blockToMine, false);
        }

        return true;
    }
}