Jump to content

[1.7.10] Help With CraftingHander


Pikachu923

Recommended Posts

Please help me, I don't know what I did wrong. I am trying to make the item take durability damage on crafting in minecraft 1.7.10. (P.S I am new to modding)

 

 

 

package com.pikachu923.BananaCraft.Handler;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import org.apache.logging.log4j.Level;

import com.pikachu923.BananaCraft.init.*;
import com.pikachu923.BananaCraft.utility.LogHelper;

public class CraftingHandler {

@SubscribeEvent
    public void onItemCraftedEvent(PlayerEvent.ItemCraftedEvent event) {
	LogHelper.Log(Level.DEBUG, "onCrafting Loaded");
	for(int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
		//if  (event.craftMatrix.getStackInSlot(i) != null) {

			ItemStack item0 = event.craftMatrix.getStackInSlot(i);
					if(item0 != null && item0.getItem() == Tier1Items.BananaLifeCore) {
						Item l = event.craftMatrix.getStackInSlot(i).getItem();
						ItemStack k = new ItemStack(l, 1, (item0.getItemDamage() + 1));

						if(k.getItemDamage() >= k.getMaxDamage()) {
							k.stackSize = 0;

						}

						event.craftMatrix.setInventorySlotContents(i, k);
					}

			/*ItemStack item1 = event.craftMatrix.getStackInSlot(i);
					if(item1 != null && item1.getItem() == Tier1Items.BananaLifeCore) {
						ItemStack k = new ItemStack(Tier1Items.BananaLifeCore, 1, (item0.getItemDamage() + 1))

						if(k.getItemDamage() >= k.getMaxDamage()) {
							k.stackSize--;

						}

						event.craftMatrix.setInventorySlotContents(i, k);
					}*/

	}
}
}

 

 

 

Thanks in advanced

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.