Skip to content

Commit

Permalink
Fire a SmelteryCastedEvent when a casting table finished casting an i…
Browse files Browse the repository at this point in the history
…tem. Allows to change/modify the output and consume the cast.
  • Loading branch information
bonii-xx committed Aug 6, 2014
1 parent d5829b0 commit 3cab9c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/main/java/tconstruct/library/event/SmelteryCastedEvent.java
@@ -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;
}


}
Expand Up @@ -22,6 +22,7 @@
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
Expand Down Expand Up @@ -339,8 +340,11 @@ public void castLiquid ()
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);
Expand Down

0 comments on commit 3cab9c0

Please sign in to comment.