Search in sources :

Example 1 with TileEntityCompostedDirt

use of com.minecolonies.coremod.tileentities.TileEntityCompostedDirt in project minecolonies by ldtteam.

the class EntityAIWorkFlorist method compost.

/**
 * Walk to the block to compost and apply compost to it.
 *
 * @return the next state to go to.
 */
private IAIState compost() {
    if (compostPosition == null) {
        return START_WORKING;
    }
    worker.getCitizenData().setVisibleStatus(GARDENING);
    if (walkToBlock(compostPosition)) {
        return getState();
    }
    final TileEntity entity = world.getBlockEntity(compostPosition);
    if (entity instanceof TileEntityCompostedDirt) {
        @Nullable final ItemStack stack = getOwnBuilding().getFlowerToGrow();
        if (stack != null) {
            if (worker.getRandom().nextInt(200 - getPrimarySkillLevel()) < 0 || InventoryUtils.shrinkItemCountInItemHandler(worker.getInventoryCitizen(), IS_COMPOST)) {
                ((TileEntityCompostedDirt) entity).compost(PERCENT_CHANGE_FOR_GROWTH - (getOwnBuilding().getBuildingLevel() * 0.01), getOwnBuilding().getFlowerToGrow());
            }
        } else {
            worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(NO_FLOWERS_IN_CONFIG), ChatPriority.BLOCKING));
        }
    }
    incrementActionsDone();
    worker.decreaseSaturationForContinuousAction();
    compostPosition = null;
    return START_WORKING;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) TileEntityCompostedDirt(com.minecolonies.coremod.tileentities.TileEntityCompostedDirt) ItemStack(net.minecraft.item.ItemStack) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with TileEntityCompostedDirt

use of com.minecolonies.coremod.tileentities.TileEntityCompostedDirt in project minecolonies by Minecolonies.

the class EntityAIWorkFlorist method compost.

/**
 * Walk to the block to compost and apply compost to it.
 *
 * @return the next state to go to.
 */
private IAIState compost() {
    if (compostPosition == null) {
        return START_WORKING;
    }
    worker.getCitizenData().setVisibleStatus(GARDENING);
    if (walkToBlock(compostPosition)) {
        return getState();
    }
    final TileEntity entity = world.getBlockEntity(compostPosition);
    if (entity instanceof TileEntityCompostedDirt) {
        @Nullable final ItemStack stack = building.getFlowerToGrow();
        if (stack != null) {
            if (worker.getRandom().nextInt(200 - getPrimarySkillLevel()) < 0 || InventoryUtils.shrinkItemCountInItemHandler(worker.getInventoryCitizen(), IS_COMPOST)) {
                ((TileEntityCompostedDirt) entity).compost(PERCENT_CHANGE_FOR_GROWTH - (building.getBuildingLevel() * 0.01), building.getFlowerToGrow());
            }
        } else {
            worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(NO_FLOWERS_IN_CONFIG), ChatPriority.BLOCKING));
        }
    }
    incrementActionsDone();
    worker.decreaseSaturationForContinuousAction();
    compostPosition = null;
    return START_WORKING;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) TileEntityCompostedDirt(com.minecolonies.coremod.tileentities.TileEntityCompostedDirt) ItemStack(net.minecraft.item.ItemStack) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

StandardInteraction (com.minecolonies.coremod.colony.interactionhandling.StandardInteraction)2 TileEntityCompostedDirt (com.minecolonies.coremod.tileentities.TileEntityCompostedDirt)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 Nullable (org.jetbrains.annotations.Nullable)2