Fire a SmelteryCastedEvent when a casting table finished casting an item. Allows to change/modify the output and consume the cast.

This commit is contained in:
Bernhard Bonigl committed 2014-08-06 15:39:29 +02:00
1 parent d5829b0fed
commit 3cab9c0063
2 files changed
+29 -2

No files matched your search

@@ -0,0 +1,23 @@
package tconstruct.library.event;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.item.ItemStack;
import tconstruct.library.crafting.CastingRecipe;
/**
* Fired when an item is cast in the casting table.
* If consumeCast is set to true, the cast will be destroyed.
*/
public class SmelteryCastedEvent extends Event {
public final CastingRecipe recipe;
public ItemStack output;
public boolean consumeCast;
public SmelteryCastedEvent(CastingRecipe recipe, ItemStack output) {
this.recipe = recipe;
this.consumeCast = recipe.consumeCast;
this.output = output;
}
}
@@ -22,6 +22,7 @@ import net.minecraftforge.fluids.IFluidTank;
import tconstruct.TConstruct;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.event.SmelteryCastEvent;
import tconstruct.library.event.SmelteryCastedEvent;
import tconstruct.library.util.IPattern;
public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
@@ -339,8 +340,11 @@ public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFl
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]);
if (recipe != null)
{
inventory[1] = recipe.getResult();
if (recipe.consumeCast)
SmelteryCastedEvent event = new SmelteryCastedEvent(recipe, recipe.getResult());
MinecraftForge.EVENT_BUS.post(event);
inventory[1] = event.output;
if (event.consumeCast)
inventory[0] = null;
liquid = null;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);