2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.library.event;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-06-30 22:26:00 -08:00
|
|
|
import tconstruct.library.tools.ToolMaterial;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.library.tools.ToolCore;
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.Event;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
/* This event fires after all of the other construction. The resulting nbttag is added to the tool
|
|
|
|
|
* Note: The tag is the base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class ToolCraftEvent extends Event
|
|
|
|
|
{
|
|
|
|
|
public final ToolCore tool;
|
|
|
|
|
public final NBTTagCompound toolTag;
|
2014-06-30 22:26:00 -08:00
|
|
|
public final ToolMaterial[] materials;
|
2013-07-26 21:18:53 -07:00
|
|
|
protected ItemStack resultStack;
|
|
|
|
|
|
2014-06-30 22:26:00 -08:00
|
|
|
public ToolCraftEvent(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
this.tool = tool;
|
|
|
|
|
this.toolTag = toolTag;
|
|
|
|
|
this.materials = materials;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HasResult
|
|
|
|
|
public static class NormalTool extends ToolCraftEvent
|
|
|
|
|
{
|
2014-06-30 22:26:00 -08:00
|
|
|
public NormalTool(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
super(tool, toolTag, materials);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Fires just before the tool is put together
|
2013-07-26 21:18:53 -07:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* Result is significant: DEFAULT: Allows tool to be crafted normally
|
|
|
|
|
* ALLOW: Uses resultStack instead DENY: Stops tool crafting altogether
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public void overrideResult (ItemStack result)
|
|
|
|
|
{
|
|
|
|
|
resultStack = result;
|
|
|
|
|
this.setResult(Result.ALLOW);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemStack getResultStack ()
|
|
|
|
|
{
|
|
|
|
|
return resultStack;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|