Search in sources :

Example 1 with ConcretePowderBlock

use of net.minecraft.block.ConcretePowderBlock in project minecolonies by Minecolonies.

the class EntityAIConcreteMixer method craft.

@Override
protected IAIState craft() {
    if (currentRecipeStorage == null) {
        return START_WORKING;
    }
    if (currentRequest == null && job.getCurrentTask() != null) {
        return GET_RECIPE;
    }
    if (walkTo == null && walkToBuilding()) {
        return getState();
    }
    currentRequest = job.getCurrentTask();
    if (currentRequest != null && (currentRequest.getState() == RequestState.CANCELLED || currentRequest.getState() == RequestState.FAILED)) {
        currentRequest = null;
        incrementActionsDone(getActionRewardForCraftingSuccess());
        currentRecipeStorage = null;
        return START_WORKING;
    }
    final ItemStack concrete = currentRecipeStorage.getPrimaryOutput();
    if (concrete.getItem() instanceof BlockItem && ((BlockItem) concrete.getItem()).getBlock() instanceof ConcretePowderBlock) {
        return super.craft();
    }
    final IAIState mixState = mixConcrete();
    if (mixState == getState()) {
        currentRequest.addDelivery(new ItemStack(concrete.getItem(), 1));
        job.setCraftCounter(job.getCraftCounter() + 1);
        if (job.getCraftCounter() >= job.getMaxCraftingCount()) {
            incrementActionsDone(getActionRewardForCraftingSuccess());
            currentRecipeStorage = null;
            resetValues();
            if (inventoryNeedsDump()) {
                if (job.getMaxCraftingCount() == 0 && job.getCraftCounter() == 0 && currentRequest != null) {
                    job.finishRequest(true);
                    worker.getCitizenExperienceHandler().addExperience(currentRequest.getRequest().getCount() / 2.0);
                }
            }
        }
    }
    return mixState;
}
Also used : IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem) ConcretePowderBlock(net.minecraft.block.ConcretePowderBlock)

Example 2 with ConcretePowderBlock

use of net.minecraft.block.ConcretePowderBlock in project minecolonies by ldtteam.

the class EntityAIConcreteMixer method craft.

@Override
protected IAIState craft() {
    if (currentRecipeStorage == null) {
        return START_WORKING;
    }
    if (currentRequest == null && job.getCurrentTask() != null) {
        return GET_RECIPE;
    }
    if (walkTo == null && walkToBuilding()) {
        return getState();
    }
    currentRequest = job.getCurrentTask();
    if (currentRequest != null && (currentRequest.getState() == RequestState.CANCELLED || currentRequest.getState() == RequestState.FAILED)) {
        currentRequest = null;
        incrementActionsDone(getActionRewardForCraftingSuccess());
        currentRecipeStorage = null;
        return START_WORKING;
    }
    final ItemStack concrete = currentRecipeStorage.getPrimaryOutput();
    if (concrete.getItem() instanceof BlockItem && ((BlockItem) concrete.getItem()).getBlock() instanceof ConcretePowderBlock) {
        return super.craft();
    }
    final IAIState mixState = mixConcrete();
    if (mixState == getState()) {
        currentRequest.addDelivery(new ItemStack(concrete.getItem(), 1));
        job.setCraftCounter(job.getCraftCounter() + 1);
        if (job.getCraftCounter() >= job.getMaxCraftingCount()) {
            incrementActionsDone(getActionRewardForCraftingSuccess());
            currentRecipeStorage = null;
            resetValues();
            if (inventoryNeedsDump()) {
                if (job.getMaxCraftingCount() == 0 && job.getCraftCounter() == 0 && currentRequest != null) {
                    job.finishRequest(true);
                    worker.getCitizenExperienceHandler().addExperience(currentRequest.getRequest().getCount() / 2.0);
                }
            }
        }
    }
    return mixState;
}
Also used : IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem) ConcretePowderBlock(net.minecraft.block.ConcretePowderBlock)

Aggregations

IAIState (com.minecolonies.api.entity.ai.statemachine.states.IAIState)2 ConcretePowderBlock (net.minecraft.block.ConcretePowderBlock)2 BlockItem (net.minecraft.item.BlockItem)2 ItemStack (net.minecraft.item.ItemStack)2