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);
}
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--;
}
}
}
}
}
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));
}
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);
}
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);
}
}
Aggregations