Hi all!
So last night, I received some help on another forum creating an auto-smelt enchantment. What currently happens with the enchantment is that if you mine a block with a smelting recipe, it'll only drop the smelted result. However, this only works the first time you use the enchantment on a block. What I mean is that if you mine a block of Gold Ore with auto-smelt, it'll drop a Gold Ingot. Then you could go and mine an Iron Ore and it would drop an Iron Ingot. If you were to then mine Gold Ore again, nothing would be dropped at all. Here is the event code (apologies, couldn't get the code button to work):
package SkyeStark.Rhencraft.main;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.event.world.BlockEvent;
import scala.actors.threadpool.Arrays;
public class AutoSmelt {
int j = 0;
int i;
@SubscribeEvent
public void onHarvestDrops(BlockEvent.HarvestDropsEvent event)
{
System.out.println(event.drops);
System.out.println("Event has started");
if(event.harvester != null){
System.out.println("Harvester exists");
ItemStack heldItem = event.harvester.inventory.getCurrentItem();
if (heldItem != null && heldItem.getItem() == MainClass.toolRheniumPickaxe)
{
System.out.println("Found Pickaxe");
int enchantmentLevel = EnchantmentHelper.getEnchantmentLevel(MainClass.autoSmelt.effectId, heldItem);
if (enchantmentLevel > 0 && event.harvester.inventory.hasItem(Items.coal))
{
System.out.println("Level is more than 0");
ItemStack smelted = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block).copy());
if (smelted != null)
{
System.out.println("" + smelted + " will be added to the drops");
event.drops.clear();
j = j + 1;
if(j >= {
j = 0;
event.harvester.inventory.consumeInventoryItem(Items.coal);
}
System.out.println("J is equal to " + j);
event.drops.add(smelted);
}
}
}
}
}
}
There is no reason why the smelted item should not be dropped, is there?