Jump to content

meta sensitive input furnace


Alix_The_Alicorn

Recommended Posts

I solved my original issue, scroll down I ask another question about how to make my custom furnace have metadata sensitive input.

 

EDIT: SCROLL DOWN! MORE INFO ABOUT STUFF IS DOWN THERE|

                                                                                              V

Link to comment
Share on other sites

Don't see anything random in your code...

Do you really want to duplicate your chisel when it is on the crafting bench ?  (stacksize = 2  ???)

And you are checking all slots here, without stopping at the first chisel found.

 

What is the recipe calling your crafting handler ? it should contain a chisel.

Link to comment
Share on other sites

Ok, I've done my randomly breaking!! :D :D :D

 

I still need help with making my "Compression Chamber" have metadata sensitive input.

 

my code for randomly breaking the chisel or not breaking it is this:

package com.jmanpenilla.carbonmod.core.handlers;

import java.util.Random;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;

import com.jmanpenilla.carbonmod.item.Items;
import com.jmanpenilla.carbonmod.lib.Reference;

import cpw.mods.fml.common.ICraftingHandler;

/**
* CarbonMod
* 
* @author jmanpenilla
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
* 
*/

public class CraftingHandler implements ICraftingHandler{

@Override
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) 
{

	final int x = 1;
	final int y = Reference.chiselBreakTime;
	int rand = new Random().nextInt(y-x) + x;

	for(int i=0; i < craftMatrix.getSizeInventory(); i++) //Checks all the slots
	{               
		if(craftMatrix.getStackInSlot(i) != null) //If there is an item
		{

			ItemStack j = craftMatrix.getStackInSlot(i); //Gets the item

			if(j.getItem() != null && j.getItem() == Items.chisel && j.getItemDamage() == 0 && rand == 2)
			{
				ItemStack l = new ItemStack(Items.chisel, 2, 1);
				craftMatrix.setInventorySlotContents(i, l);
			}

			else if(j.getItem() != null && j.getItem() == Items.chisel && j.getItemDamage() == 0)
			{
				ItemStack k = new ItemStack(Items.chisel, 2, (j.getItemDamage() + 0)); //Makes a new itemstack that's been damaged and has 2 items
				craftMatrix.setInventorySlotContents(i, k); //Sets the slot to the new item     
			}

		}
	}
}
@Override
public void onSmelting(EntityPlayer player, ItemStack item) {

}
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.