Also fire cast-events for CastingBasin. Add separate events for CastingBasin and CastingTable.

This commit is contained in:
Bernhard Bonigl committed 2014-08-06 15:57:06 +02:00
1 parent 3cab9c0063
commit 0821f9f77f
5 files changed
+45 -6

No files matched your search

@@ -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);
}
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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;
@@ -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;