Search in sources :

Example 6 with DecomposerRecipe

use of minechem.tileentity.decomposer.DecomposerRecipe in project Minechem by iopleke.

the class DecomposerNEIRecipeHandler method loadUsageRecipes.

@Override
public void loadUsageRecipes(ItemStack ingredient) {
    // Add all decomposer recipes that take the ingredient as an input.
    DecomposerRecipe dr = DecomposerRecipeHandler.instance.getRecipe(ingredient);
    if (dr != null) {
        registerDecomposerRecipe(dr);
    }
    arecipes = sortList(arecipes);
}
Also used : DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe)

Example 7 with DecomposerRecipe

use of minechem.tileentity.decomposer.DecomposerRecipe in project Minechem by iopleke.

the class PolytoolEventHandler method onDrop.

@SubscribeEvent
public void onDrop(LivingDropsEvent event) {
    // Thanks to mDiyo
    if ("player".equals(event.source.damageType)) {
        EntityPlayer player = (EntityPlayer) event.source.getEntity();
        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem() instanceof PolytoolItem) {
            float powerSilicon = PolytoolItem.getPowerOfType(stack, ElementEnum.Si);
            if (powerSilicon > 0) {
                int amount = (int) Math.ceil(random.nextDouble() * powerSilicon);
                Iterator iter = event.drops.iterator();
                if (random.nextInt(16) < 1 + powerSilicon) {
                    ArrayList<EntityItem> trueResult = new ArrayList<EntityItem>();
                    while (iter.hasNext()) {
                        EntityItem entityItem = (EntityItem) iter.next();
                        ItemStack item = entityItem.getEntityItem();
                        while (item.stackSize > 0) {
                            // Always avoid chances
                            DecomposerRecipe recipe = DecomposerRecipeHandler.instance.getRecipe(item);
                            if (recipe != null) {
                                ArrayList<ItemStack> items = MinechemUtil.convertChemicalsIntoItemStacks(recipe.getOutput());
                                for (ItemStack itemStack : items) {
                                    trueResult.add(new EntityItem(entityItem.worldObj, entityItem.posX, entityItem.posY, entityItem.posZ, itemStack));
                                }
                            } else {
                                trueResult.add(entityItem);
                                break;
                            }
                            item.stackSize--;
                        }
                    }
                    event.drops.clear();
                    event.drops.addAll(trueResult);
                }
            }
        }
        if (event.entityLiving instanceof EntitySkeleton || event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntityPlayer) {
            EntityLivingBase enemy = event.entityLiving;
            if (stack != null && stack.getItem() instanceof PolytoolItem) {
                // Nitrogen preservation
                if (enemy instanceof EntityZombie) {
                    float power = PolytoolItem.getPowerOfType(stack, ElementEnum.N);
                    if (power > 0) {
                        int amount = (int) Math.ceil(random.nextDouble() * power);
                        addDrops(event, new ItemStack(Items.cooked_beef, amount, 0));
                        Iterator iter = event.drops.iterator();
                        while (iter.hasNext()) {
                            EntityItem entityItem = (EntityItem) iter.next();
                            if (entityItem.getEntityItem().getItem() == Items.rotten_flesh) {
                                iter.remove();
                            }
                        }
                    }
                }
                // Calcium bonus
                if (enemy instanceof EntitySkeleton) {
                    float power = PolytoolItem.getPowerOfType(stack, ElementEnum.Ca);
                    if (power > 0) {
                        int amount = (int) Math.ceil(random.nextDouble() * power);
                        Iterator iter = event.drops.iterator();
                        while (iter.hasNext()) {
                            EntityItem entityItem = (EntityItem) iter.next();
                            if (entityItem.getEntityItem().getItem() == Items.bone) {
                                entityItem.getEntityItem().stackSize += amount;
                            }
                        }
                    }
                }
                // Beryllium beheading
                float beheading = PolytoolItem.getPowerOfType(stack, ElementEnum.Be);
                while (beheading > 5) {
                    if (beheading > 0 && random.nextInt(5) < beheading * 10) {
                        if (event.entityLiving instanceof EntitySkeleton) {
                            EntitySkeleton skeleton = (EntitySkeleton) enemy;
                            addDrops(event, new ItemStack(Items.skull, 1, skeleton.getSkeletonType()));
                        } else if (event.entityLiving instanceof EntityZombie) {
                            addDrops(event, new ItemStack(Items.skull, 1, 2));
                        } else if (event.entityLiving instanceof EntityPlayer) {
                            ItemStack dropStack = new ItemStack(Items.skull, 1, 3);
                            NBTTagCompound nametag = new NBTTagCompound();
                            nametag.setString("SkullOwner", player.getDisplayName());
                            addDrops(event, dropStack);
                        }
                    }
                    // More head drops if level>5
                    beheading--;
                }
            }
        }
    }
}
Also used : EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityZombie(net.minecraft.entity.monster.EntityZombie) Iterator(java.util.Iterator) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 8 with DecomposerRecipe

use of minechem.tileentity.decomposer.DecomposerRecipe in project Minechem by iopleke.

the class MoleculeEnum method registerMTMolecule.

public static void registerMTMolecule(MoleculeEnum molecule) {
    addMapping(molecule);
    ArrayList<PotionChemical> var5 = molecule.components();
    PotionChemical[] var6 = var5.toArray(new PotionChemical[var5.size()]);
    ItemStack var7 = new ItemStack(MinechemItemsRegistration.molecule, 1, molecule.id());
    DecomposerRecipe.add(new DecomposerRecipe(var7, var6));
    SynthesisRecipe.add(new SynthesisRecipe(var7, true, MinechemRecipes.COST_ITEM, var6));
}
Also used : SynthesisRecipe(minechem.tileentity.synthesis.SynthesisRecipe) PotionChemical(minechem.potion.PotionChemical) DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 9 with DecomposerRecipe

use of minechem.tileentity.decomposer.DecomposerRecipe in project Minechem by iopleke.

the class DecomposerNEIRecipeHandler method loadCraftingRecipes.

@Override
public void loadCraftingRecipes(ItemStack result) {
    // can yield it.
    if (!Compare.isStackAChemical(result)) {
        return;
    }
    // Add all decomposer recipes that can yield the result.
    PotionChemical resultChemical = MinechemUtil.itemStackToChemical(result);
    if (resultChemical == null) {
        return;
    }
    for (DecomposerRecipe dr : DecomposerRecipe.recipes.values()) {
        if (dr.outputContains(resultChemical)) {
            registerDecomposerRecipe(dr);
        }
    }
    arecipes = sortList(arecipes);
}
Also used : PotionChemical(minechem.potion.PotionChemical) DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe)

Example 10 with DecomposerRecipe

use of minechem.tileentity.decomposer.DecomposerRecipe in project Minechem by iopleke.

the class DecomposerNEIRecipeHandler method loadCraftingRecipes.

@Override
public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals(MINECHEM_DECOMPOSER_RECIPES_ID)) {
        // Add all decomposer recipes to local arecipes array.
        for (DecomposerRecipe dr : DecomposerRecipe.recipes.values()) {
            ItemStack input = dr.getInput().copy();
            if (input.getItem() == null)
                continue;
            if (input.getItemDamage() == Short.MAX_VALUE) {
                // Handle OreDict wildcard
                input.setItemDamage(0);
            }
            LogHelper.debug(input.getDisplayName());
            registerDecomposerRecipe(dr);
        }
        arecipes = sortList(arecipes);
    } else {
        super.loadCraftingRecipes(outputId, results);
    }
}
Also used : DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

DecomposerRecipe (minechem.tileentity.decomposer.DecomposerRecipe)17 ItemStack (net.minecraft.item.ItemStack)10 SynthesisRecipe (minechem.tileentity.synthesis.SynthesisRecipe)8 PotionChemical (minechem.potion.PotionChemical)7 ArrayList (java.util.ArrayList)5 MoleculeEnum (minechem.item.molecule.MoleculeEnum)5 Element (minechem.item.element.Element)4 Molecule (minechem.item.molecule.Molecule)3 DecomposerRecipeSelect (minechem.tileentity.decomposer.DecomposerRecipeSelect)3 Iterator (java.util.Iterator)2 ElementEnum (minechem.item.element.ElementEnum)2 DecomposerRecipeChance (minechem.tileentity.decomposer.DecomposerRecipeChance)2 MapKey (minechem.utils.MapKey)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ILuaContext (dan200.computercraft.api.lua.ILuaContext)1 LuaException (dan200.computercraft.api.lua.LuaException)1 IComputerAccess (dan200.computercraft.api.peripheral.IComputerAccess)1 HashMap (java.util.HashMap)1 List (java.util.List)1 LuaMethod (minechem.computercraft.lua.LuaMethod)1