diff --git a/src/main/java/tconstruct/library/event/SmelteryCastEvent.java b/src/main/java/tconstruct/library/event/SmelteryCastEvent.java index 21b6d90f..c384bc7c 100644 --- a/src/main/java/tconstruct/library/event/SmelteryCastEvent.java +++ b/src/main/java/tconstruct/library/event/SmelteryCastEvent.java @@ -9,7 +9,7 @@ import tconstruct.library.crafting.CastingRecipe; * * Set result to DENY to prevent casting. */ -public class SmelteryCastEvent extends Event { +public abstract class SmelteryCastEvent extends Event { public final CastingRecipe recipe; public final FluidStack fluid; @@ -17,4 +17,16 @@ public class SmelteryCastEvent extends Event { this.recipe = recipe; this.fluid = fluid; } + + public static class CastingTable extends SmelteryCastEvent { + public CastingTable(CastingRecipe recipe, FluidStack fluid) { + super(recipe, fluid); + } + } + + public static class CastingBasin extends SmelteryCastEvent { + public CastingBasin(CastingRecipe recipe, FluidStack fluid) { + super(recipe, fluid); + } + } } diff --git a/src/main/java/tconstruct/library/event/SmelteryCastedEvent.java b/src/main/java/tconstruct/library/event/SmelteryCastedEvent.java index bf98d3c9..f0c420b1 100644 --- a/src/main/java/tconstruct/library/event/SmelteryCastedEvent.java +++ b/src/main/java/tconstruct/library/event/SmelteryCastedEvent.java @@ -8,7 +8,7 @@ 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 abstract class SmelteryCastedEvent extends Event { public final CastingRecipe recipe; public ItemStack output; public boolean consumeCast; @@ -20,4 +20,15 @@ public class SmelteryCastedEvent extends Event { } + public static class CastingTable extends SmelteryCastedEvent { + public CastingTable(CastingRecipe recipe, ItemStack output) { + super(recipe, output); + } + } + + public static class CastingBasin extends SmelteryCastedEvent { + public CastingBasin(CastingRecipe recipe, ItemStack output) { + super(recipe, output); + } + } } diff --git a/src/main/java/tconstruct/smeltery/logic/CastingBasinLogic.java b/src/main/java/tconstruct/smeltery/logic/CastingBasinLogic.java index 88df7d35..b6521828 100644 --- a/src/main/java/tconstruct/smeltery/logic/CastingBasinLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/CastingBasinLogic.java @@ -1,5 +1,6 @@ package tconstruct.smeltery.logic; +import cpw.mods.fml.common.eventhandler.Event; import mantle.blocks.abstracts.InventoryLogic; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -10,6 +11,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidEvent; @@ -19,6 +21,8 @@ import net.minecraftforge.fluids.IFluidHandler; 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 CastingBasinLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory @@ -120,6 +124,13 @@ public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFl CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(resource, inventory[0]); if (recipe == null) return 0; + + SmelteryCastEvent event = new SmelteryCastEvent.CastingBasin(recipe, resource); + MinecraftForge.EVENT_BUS.post(event); + + if(event.getResult() == Event.Result.DENY) + return 0; + this.capacity = updateCapacity(recipe.castingMetal.amount); if (inventory[1] == null) @@ -328,8 +339,11 @@ public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFl CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(liquid, inventory[0]); if (recipe != null) { - inventory[1] = recipe.getResult(); - if (recipe.consumeCast) + SmelteryCastedEvent event = new SmelteryCastedEvent.CastingBasin(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); diff --git a/src/main/java/tconstruct/smeltery/logic/CastingTableLogic.java b/src/main/java/tconstruct/smeltery/logic/CastingTableLogic.java index e2954610..1bdbac81 100644 --- a/src/main/java/tconstruct/smeltery/logic/CastingTableLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/CastingTableLogic.java @@ -125,7 +125,7 @@ public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFl if (recipe == null) return 0; - SmelteryCastEvent event = new SmelteryCastEvent(recipe, resource); + SmelteryCastEvent event = new SmelteryCastEvent.CastingTable(recipe, resource); MinecraftForge.EVENT_BUS.post(event); if(event.getResult() == Event.Result.DENY) @@ -340,7 +340,7 @@ public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFl CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]); if (recipe != null) { - SmelteryCastedEvent event = new SmelteryCastedEvent(recipe, recipe.getResult()); + SmelteryCastedEvent event = new SmelteryCastedEvent.CastingTable(recipe, recipe.getResult()); MinecraftForge.EVENT_BUS.post(event); inventory[1] = event.output; diff --git a/src/main/java/tconstruct/tools/TinkerToolEvents.java b/src/main/java/tconstruct/tools/TinkerToolEvents.java index 67196bb1..c32ed42b 100644 --- a/src/main/java/tconstruct/tools/TinkerToolEvents.java +++ b/src/main/java/tconstruct/tools/TinkerToolEvents.java @@ -30,6 +30,8 @@ import tconstruct.armor.TinkerArmor; import tconstruct.armor.player.TPlayerStats; import tconstruct.library.TConstructRegistry; import tconstruct.library.event.PartBuilderEvent; +import tconstruct.library.event.SmelteryCastEvent; +import tconstruct.library.event.SmelteryCastedEvent; import tconstruct.library.event.ToolCraftEvent; import tconstruct.library.tools.AbilityHelper; import tconstruct.library.tools.ArrowMaterial;