Search in sources :

Example 11 with RecipeData

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

the class OneToNoneRecipes method add.

public void add(@Nonnull final IItemStack item) {
    if (item == null)
        throw new IllegalArgumentException("item cannot be null");
    final RecipeData data = new RecipeData();
    data.setInput(CraftTweakerMC.getItemStack(item));
    CraftTweakerIntegration.defer("Add item " + data + " to " + this.name, () -> {
        this.recipes.add(data);
        CraftTweakerAPI.logInfo(this.name + ": Added item " + data);
    });
}
Also used : RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 12 with RecipeData

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

the class OneToOneRecipes method addRecipe.

public void addRecipe(@Nonnull final IItemStack output, @Nonnull final IItemStack input) {
    if (output == null)
        throw new IllegalArgumentException("output cannot be null");
    if (input == null)
        throw new IllegalArgumentException("input cannot be null");
    final RecipeData data = new RecipeData();
    data.setOutput(CraftTweakerMC.getItemStack(output));
    data.setInput(CraftTweakerMC.getItemStack(input));
    CraftTweakerIntegration.defer("Add recipe " + data + " to " + this.name, () -> {
        this.recipes.add(data);
        CraftTweakerAPI.logInfo(this.name + ": Added recipe " + data);
    });
}
Also used : RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 13 with RecipeData

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

the class TileEntityMicrowave method update.

@Override
public void update() {
    if (cooking) {
        if (this.world.isRemote) {
            double posX = pos.getX() + 0.35D + (rand.nextDouble() / 3);
            double posZ = pos.getZ() + 0.35D + (rand.nextDouble() / 3);
            ParticleSpawner.spawnParticle("smoke", posX, pos.getY() + 0.065D, posZ);
        }
        progress++;
        if (progress >= 40) {
            if (!getStackInSlot(0).isEmpty()) {
                RecipeData data = RecipeAPI.getMicrowaveRecipeFromIngredients(getStackInSlot(0));
                if (data != null) {
                    this.setInventorySlotContents(0, data.getOutput().copy());
                }
            }
            if (world.isRemote) {
                world.playSound(pos.getX(), pos.getY(), pos.getZ(), FurnitureSounds.microwave_finish, SoundCategory.BLOCKS, 0.75F, 1.0F, true);
            }
            timer = 0;
            progress = 0;
            cooking = false;
            world.updateComparatorOutputLevel(pos, blockType);
        } else {
            if (timer == 20) {
                timer = 0;
            }
            if (timer == 0) {
                world.playSound(pos.getX(), pos.getY(), pos.getZ(), FurnitureSounds.microwave_running, SoundCategory.BLOCKS, 0.75F, 1.0F, true);
            }
            timer++;
        }
    }
}
Also used : RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 14 with RecipeData

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

the class TileEntityMicrowave method startCooking.

public void startCooking() {
    if (!getStackInSlot(0).isEmpty()) {
        RecipeData data = RecipeAPI.getMicrowaveRecipeFromIngredients(getStackInSlot(0));
        if (data != null) {
            cooking = true;
            world.updateComparatorOutputLevel(pos, blockType);
        }
    }
}
Also used : RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 15 with RecipeData

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

the class TileEntityToaster method update.

@Override
public void update() {
    if (toasting) {
        if (toastingTime == 200) {
            for (int i = 0; i < slots.length; i++) {
                if (slots[i] != null) {
                    if (!world.isRemote) {
                        RecipeData data = RecipeAPI.getToasterRecipeFromInput(slots[i]);
                        EntityItem entityItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.6, pos.getZ() + 0.5, data.getOutput().copy());
                        world.spawnEntity(entityItem);
                    }
                    slots[i] = null;
                }
            }
            if (!world.isRemote) {
                world.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, FurnitureSounds.toaster_down, SoundCategory.BLOCKS, 0.75F, 1.0F);
            }
            toastingTime = 0;
            toasting = false;
            TileEntityUtil.markBlockForUpdate(world, pos);
            world.updateComparatorOutputLevel(pos, blockType);
        } else {
            toastingTime++;
        }
    }
}
Also used : EntityItem(net.minecraft.entity.item.EntityItem) 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