Posted June 16, 201312 yr Today I was trying to make certain features of my mod work with all other mods. I got the first one to work perfectly fine but The second (And last) one has been giving me trouble. I've been trying to get my block to "smelt" whatever you hit it with. (Say one takes iron ore, when the player hits the block while holding the ore it would smelt some it and and drop the corresponding smelting result, which in this case would be iron ingots. This enables it to work with other mods ores and smelting ingredients such as copper! The block is supposed to be an end game item that smelts things way faster than any furnace, if you were wondering) However after I hit it for the first time it doesn't seem to work, as every time I hit it afterwards it doesn't drop anything, but all conditions seem to be met. Hopefully someone here will know what the problem is. package mod_Rareores; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.util.Icon; import net.minecraft.world.World; public class BlockSmeltingBlock extends Block { Random generator = new Random(); @SideOnly(Side.CLIENT) private Icon Block_Top; public BlockSmeltingBlock(int par1) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); } public void onBlockClicked(World world, int par2, int par3, int par4, EntityPlayer player) { ItemStack stack = player.inventory.getCurrentItem(); int size; if(stack==null){ player.setFire(4); return; } if(stack != null && player.inventory.hasItem(Item.coal.itemID)){ ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(player.getHeldItem()); if(itemstack != null) { size=stack.stackSize; if(size > 8 && size <= 64) { stack.stackSize -= 8; if(!world.isRemote) { player.entityDropItem(itemstack, 0.0F); } } else { if(!world.isRemote) { player.inventory.setInventorySlotContents(player.inventory.currentItem, null); player.entityDropItem(itemstack, 0.0F); } } } } } public Icon getIcon(int par1, int par2) { return par1 == 1 ? this.Block_Top : (this.blockIcon); } public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("Rareores:SmeltSide"); this.Block_Top = par1IconRegister.registerIcon("Rareores:SmeltTop"); } } Thanks in advance! ~Noah This is the creator of the Rareores mod! Be sure to check it out at
June 16, 201312 yr Good idea^^" i know what the problem is. You are using the wrong function for the RightClicking. It has to be look like this: public boolean onBlockActivated(World par1, int par2, int par3, int par4, EntityPlayer par5, int par6, float par7, float par8, float par9) { ItemStack item = par5.getCurrentEquippedItem(); if(item != null && par5.inventory.hasItem(Item.coal.itemID) { int size = item.getItem().stackSize; if(size > { ItemStack output = FurnaceRecipes.smelting().getRecipeOutput(item); if(output != null) { ItemStack realOutput = output; realOutput.stackSize = 8; if(!(par5.inventor.addItemStackToInventory(realOutput))) { par5.entityDropItem(realoutput, 0.0F); par5.getCurrentEquippedItem()getItem().stacksize-=8; } else { par5.addItemStackToInventory(realoutput); par5.getCurrentEquippedItem().getItem().stacksize-=8; } } } } else { par5.setFire(4); return true; } return true; } It had to look like this. There could be some mistakes in my code because i wrote it free out of my mind (i am at my mobilephone). But i think that is the way you should go^^" I hope it helps
June 16, 201312 yr Author You had it partially right, IT DID need to be onblockactivated but there were other hidden problems within the code that I ended up fixing, but thanks for the help! This is the creator of the Rareores mod! Be sure to check it out at
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.