Search in sources :

Example 1 with OfferingRecipe

use of com.mart.solar.api.recipes.OfferingRecipe in project Solar by Martacus.

the class TileOfferingShrine method update.

@Override
public void update() {
    if (!this.offeringRecipe.equalsIgnoreCase("")) {
        if (this.runningTicks <= OFFERING_TICKS) {
            runningTicks++;
        } else {
            OfferingRecipe recipe = OfferingRecipeRegister.getByRegistrationName(this.offeringRecipe);
            if (recipe == null) {
                return;
            }
            if (!this.world.isRemote) {
                this.world.spawnEntity(new EntityItem(this.world, this.getPos().getX(), this.getPos().getY() + 10, this.getPos().getZ(), recipe.getOutputStack()));
            }
            this.offeringRecipe = "";
            this.runningTicks = 0;
            this.itemStackHandler.clear();
        }
    }
}
Also used : OfferingRecipe(com.mart.solar.api.recipes.OfferingRecipe) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with OfferingRecipe

use of com.mart.solar.api.recipes.OfferingRecipe in project Solar by Martacus.

the class ModRecipes method registerRecipes.

@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
    OreDictionary.registerOre("oreSilver", ModBlocks.SILVER_ORE);
    OreDictionary.registerOre("ingotSilver", ModItems.SILVER_INGOT);
    OreDictionary.registerOre("nuggetSilver", ModItems.SILVER_NUGGET);
    GameRegistry.addSmelting(ModBlocks.SILVER_ORE, new ItemStack(ModItems.SILVER_INGOT, 1), 1.5f);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.BLAZE_POWDER, RuneType.FIRE, 2), "blaze_powder_fire", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.COAL, RuneType.FIRE, 1), "coal_fire", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.GUNPOWDER, RuneType.FIRE, 3), "gunpowder_fire", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.POTIONITEM, RuneType.WATER, 1), "water_bottle_water", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(ItemBlock.getByNameOrId("stone"), RuneType.EARTH, 1), "stone_earth", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.FEATHER, RuneType.WIND, 1), "feather_wind", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.DIAMOND, RuneType.TIME, 2), "diamond_time", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.BONE, RuneType.LIFE, 1), "bone_life", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(Items.GOLD_NUGGET, RuneType.SUN, 1), "gold_nugget_sun", true);
    InfuserReagentRegistry.registerReagent(new InfuserReagent(ModItems.SILVER_NUGGET, RuneType.MOON, 1), "silver_nugget_sun", true);
    AltarRecipeRegistry.registerRecipe(new AltarRecipe(Ingredient.fromItem(ModItems.DULL_AMULET), new ItemStack(ModItems.RITUAL_AMULET), 500), "ritual_amulet", true);
    AltarRecipeRegistry.registerRecipe(new AltarRecipe(Ingredient.fromItem(Item.getItemFromBlock(Blocks.PLANKS)), new ItemStack(ModItems.RUNES), 100), "rune", true);
    AltarRecipeRegistry.registerRecipe(new AltarRecipe(Ingredient.fromItem(Items.BOOK), new ItemStack(ModItems.JOURNAL), 100), "journal", true);
    AltarRecipeRegistry.registerRecipe(new AltarRecipe(Ingredient.fromItem(Item.getItemFromBlock(Blocks.STONE)), new ItemStack(Item.getItemFromBlock(ModBlocks.SUNBURNT)), 50), "sunburnt_stone", true);
    AltarRecipeRegistry.registerRecipe(new AltarRecipe(Ingredient.fromItem(Items.GOLD_INGOT), new ItemStack(ModItems.INFUSED, 1, 0), 400), "infused_gold", true);
    AltarRecipeRegistry.registerRecipe(new AltarRecipe(Ingredient.fromItem(ModItems.SILVER_INGOT), new ItemStack(ModItems.INFUSED, 1, 1), 400), "infused_silver", true);
    OfferingRecipeRegister.registerRecipe(new OfferingRecipe(new ItemStack(ModItems.RING_FLIGHT), Items.FEATHER, Items.FEATHER, Items.FEATHER, Items.FEATHER, Items.FEATHER, Items.FEATHER, Items.FEATHER, Items.FEATHER), "ring_of_flight", true);
}
Also used : OfferingRecipe(com.mart.solar.api.recipes.OfferingRecipe) InfuserReagent(com.mart.solar.api.infusing.InfuserReagent) AltarRecipe(com.mart.solar.api.recipes.AltarRecipe) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with OfferingRecipe

use of com.mart.solar.api.recipes.OfferingRecipe in project Solar by Martacus.

the class TileOfferingShrine method onUse.

public void onUse(EntityPlayer player, EnumHand hand) {
    ItemStack heldItem = player.getHeldItem(hand);
    if (heldItem.getItem() == ModItems.RITUAL_AMULET) {
        if (!this.validMultiblock()) {
            // todo: let player know multiblock aint valid maybe?
            return;
        }
        LinkedList<ItemStack> itemStacks = this.itemStackHandler.getOfferItemStacks();
        List<OfferingRecipe> offeringRecipes = OfferingRecipeRegister.getRecipes();
        for (OfferingRecipe recipe : offeringRecipes) {
            boolean matches = true;
            List<Ingredient> ingredients = recipe.getIngredients();
            for (int i = 7; i >= 0; i--) {
                ItemStack ingredientStack = ingredients.get(i).getMatchingStacks()[0];
                if (!itemStacks.get(i).isItemEqual(ingredientStack)) {
                    matches = false;
                }
            }
            if (matches) {
                this.offeringRecipe = OfferingRecipeRegister.getRegistrationName(recipe);
                notifyUpdate();
                break;
            }
        }
        return;
    }
    ItemStack returnStack;
    ItemStack insertStack = heldItem.copy();
    insertStack.setCount(1);
    returnStack = this.itemStackHandler.insertItem(insertStack, false);
    if (returnStack.isEmpty()) {
        if (heldItem.getCount() <= 1) {
            player.setHeldItem(hand, ItemStack.EMPTY);
        } else {
            heldItem.setCount(heldItem.getCount() - 1);
        }
    }
    notifyUpdate();
}
Also used : Ingredient(net.minecraft.item.crafting.Ingredient) OfferingRecipe(com.mart.solar.api.recipes.OfferingRecipe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

OfferingRecipe (com.mart.solar.api.recipes.OfferingRecipe)3 ItemStack (net.minecraft.item.ItemStack)2 InfuserReagent (com.mart.solar.api.infusing.InfuserReagent)1 AltarRecipe (com.mart.solar.api.recipes.AltarRecipe)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Ingredient (net.minecraft.item.crafting.Ingredient)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1