Search in sources :

Example 16 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class TileEntityGrill method update.

@Override
public void update() {
    if (!world.isRemote) {
        if (fire) {
            if (inventory[0] != null) {
                RecipeData dataLeft = RecipeAPI.getGrillRecipeFromInput(inventory[0]);
                if (dataLeft != null) {
                    if (leftCookTime >= COOK_DURATION) {
                        if (!leftCooked) {
                            if (flippedLeft) {
                                inventory[0] = dataLeft.getOutput().copy();
                            }
                            leftCooked = true;
                            TileEntityUtil.markBlockForUpdate(world, pos);
                            leftSoundLoop = 0;
                        }
                        if (leftSoundLoop % 20 == 0) {
                            world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 0.5F);
                        }
                    } else {
                        if (leftSoundLoop % 20 == 0) {
                            if (!leftCooked) {
                                if (flippedLeft && leftCookTime >= 20) {
                                    world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
                                } else if (!flippedLeft) {
                                    world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
                                }
                            }
                        }
                        leftCookTime++;
                    }
                    leftSoundLoop++;
                }
            }
            if (inventory[1] != null) {
                RecipeData dataRight = RecipeAPI.getGrillRecipeFromInput(inventory[1]);
                if (dataRight != null) {
                    if (rightCookTime >= COOK_DURATION) {
                        if (!rightCooked) {
                            if (flippedRight) {
                                inventory[1] = dataRight.getOutput().copy();
                            }
                            rightCooked = true;
                            TileEntityUtil.markBlockForUpdate(world, pos);
                            rightSoundLoop = 0;
                        }
                        if (rightSoundLoop % 20 == 0) {
                            world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 0.5F);
                        }
                    } else {
                        if (rightSoundLoop % 20 == 0) {
                            if (!rightCooked) {
                                if (flippedRight && rightCookTime >= 20) {
                                    world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
                                } else if (!flippedRight) {
                                    world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
                                }
                            }
                        }
                        rightCookTime++;
                    }
                    rightSoundLoop++;
                }
            }
            coalTick++;
            if (coalTick >= COAL_DURATION) {
                coalTick = 0;
                coal--;
                if (coal <= 0) {
                    fire = false;
                }
                TileEntityUtil.markBlockForUpdate(world, pos);
            }
        }
    } else {
        if (flippedLeft && leftFlipCount < FLIP_DURATION) {
            leftFlipCount++;
        }
        if (flippedRight && rightFlipCount < FLIP_DURATION) {
            rightFlipCount++;
        }
    }
}
Also used : RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 17 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class TileEntityBlender method hasValidIngredients.

public boolean hasValidIngredients() {
    RecipeData data = RecipeAPI.getBlenderRecipeDataFromIngredients(ingredients);
    if (data == null) {
        return false;
    }
    drinkName = data.getDrinkName();
    healAmount = data.getHealAmount();
    currentRed = data.getRed();
    currentGreen = data.getGreen();
    currentBlue = data.getBlue();
    return true;
}
Also used : RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 18 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class TileEntityChoppingBoard method chopFood.

public boolean chopFood() {
    if (food != null) {
        RecipeData data = RecipeAPI.getChoppingBoardRecipeFromInput(food);
        if (data != null) {
            if (!world.isRemote) {
                EntityItem entityItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.2, pos.getZ() + 0.5, data.getOutput().copy());
                world.spawnEntity(entityItem);
                world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), FurnitureSounds.knife_chop, SoundCategory.BLOCKS, 0.75F, 1.0F);
            }
            setFood(null);
            TileEntityUtil.markBlockForUpdate(world, pos);
            return true;
        }
    }
    return false;
}
Also used : EntityItem(net.minecraft.entity.item.EntityItem) RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 19 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class BlockToaster method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldItem = playerIn.getHeldItem(hand);
    TileEntity tileEntity = worldIn.getTileEntity(pos);
    if (tileEntity instanceof TileEntityToaster) {
        TileEntityToaster tileEntityToaster = (TileEntityToaster) tileEntity;
        if (!heldItem.isEmpty() && !tileEntityToaster.isToasting()) {
            RecipeData data = RecipeAPI.getToasterRecipeFromInput(heldItem);
            if (data != null) {
                if (tileEntityToaster.addSlice(new ItemStack(heldItem.getItem(), 1))) {
                    TileEntityUtil.markBlockForUpdate(worldIn, pos);
                    heldItem.shrink(1);
                }
            } else {
                tileEntityToaster.removeSlice();
            }
        } else {
            if (playerIn.isSneaking()) {
                if (!tileEntityToaster.isToasting()) {
                    tileEntityToaster.startToasting();
                    worldIn.updateComparatorOutputLevel(pos, this);
                    if (!worldIn.isRemote) {
                        worldIn.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, FurnitureSounds.toaster_down, SoundCategory.BLOCKS, 0.75F, 1.0F, false);
                    }
                }
            } else if (!tileEntityToaster.isToasting()) {
                tileEntityToaster.removeSlice();
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityToaster(com.mrcrayfish.furniture.tileentity.TileEntityToaster) ItemStack(net.minecraft.item.ItemStack) RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 20 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class ContainerWashingMachine method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) {
    ItemStack itemCopy = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(slotNum);
    if (slot != null && slot.getHasStack()) {
        ItemStack item = slot.getStack();
        itemCopy = item.copy();
        if (slotNum < 5) {
            if (!this.mergeItemStack(item, 5, this.inventorySlots.size(), false)) {
                return ItemStack.EMPTY;
            }
        } else if (slotNum > 4) {
            RecipeData data = RecipeAPI.getWashingMachineRecipeFromInput(item);
            if (data != null && (itemCopy.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN) || itemCopy.getItem() == Items.SKULL || itemCopy.getItem().getEquipmentSlot(itemCopy) != null || (itemCopy.getItem() instanceof ItemArmor && ((ItemArmor) itemCopy.getItem()).armorType != null) || EntityLiving.getSlotForItemStack(itemCopy) != EntityEquipmentSlot.HEAD)) {
                if (!this.mergeItemStack(item, 0, 4, true)) {
                    return ItemStack.EMPTY;
                } else if (slotNum > 4 && slotNum < this.inventorySlots.size() - 9) {
                    if (!this.mergeItemStack(item, this.inventorySlots.size() - 9, this.inventorySlots.size(), false)) {
                        return ItemStack.EMPTY;
                    }
                } else if (slotNum >= this.inventorySlots.size() - 9 && slotNum < this.inventorySlots.size()) {
                    if (!this.mergeItemStack(item, 5, this.inventorySlots.size() - 9, false)) {
                        return ItemStack.EMPTY;
                    }
                }
            } else if (item.getItem() == FurnitureItems.SOAPY_WATER | item.getItem() == FurnitureItems.SUPER_SOAPY_WATER) {
                if (!this.mergeItemStack(item, 4, 5, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (slotNum > 4 && slotNum < this.inventorySlots.size() - 9) {
                if (!this.mergeItemStack(item, this.inventorySlots.size() - 9, this.inventorySlots.size(), false)) {
                    return ItemStack.EMPTY;
                }
            } else if (slotNum >= this.inventorySlots.size() - 9 && slotNum < this.inventorySlots.size()) {
                if (!this.mergeItemStack(item, 5, this.inventorySlots.size() - 9, false)) {
                    return ItemStack.EMPTY;
                }
            }
        } else if (!this.mergeItemStack(item, 0, 9, false)) {
            return ItemStack.EMPTY;
        }
        if (item.getCount() == 0) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
    }
    return itemCopy;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Aggregations

RecipeData (com.mrcrayfish.furniture.api.RecipeData)33 ItemStack (net.minecraft.item.ItemStack)8 Slot (net.minecraft.inventory.Slot)6 ZenDoc (crafttweaker.annotations.ZenDoc)3 EntityItem (net.minecraft.entity.item.EntityItem)3 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)3 IItemStack (crafttweaker.api.item.IItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Recipes (com.mrcrayfish.furniture.api.Recipes)1 TileEntityComputer (com.mrcrayfish.furniture.tileentity.TileEntityComputer)1 TileEntityToaster (com.mrcrayfish.furniture.tileentity.TileEntityToaster)1 CraftTweakerAPI (crafttweaker.CraftTweakerAPI)1 ZenRegister (crafttweaker.annotations.ZenRegister)1 CraftTweakerMC (crafttweaker.api.minecraft.CraftTweakerMC)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 Predicate (java.util.function.Predicate)1 Nonnull (javax.annotation.Nonnull)1