mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Fire a SmelteryCastEvent when a castingTable tries to cast something. Allows to deny the casting.
This commit is contained in:
1 parent
6f84462215
commit
d5829b0fed
2 files changed
+30
No files matched your search
@@ -0,0 +1,20 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
|
||||
/**
|
||||
* Fires when somebody tries to pour a liquid into a metal cast.
|
||||
*
|
||||
* Set result to DENY to prevent casting.
|
||||
*/
|
||||
public class SmelteryCastEvent extends Event {
|
||||
public final CastingRecipe recipe;
|
||||
public final FluidStack fluid;
|
||||
|
||||
public SmelteryCastEvent(CastingRecipe recipe, FluidStack fluid) {
|
||||
this.recipe = recipe;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
}
|
||||
@@ -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,7 @@ 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.util.IPattern;
|
||||
|
||||
public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
|
||||
@@ -120,6 +123,13 @@ public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFl
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(resource, inventory[0]);
|
||||
if (recipe == null)
|
||||
return 0;
|
||||
|
||||
SmelteryCastEvent event = new SmelteryCastEvent(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)
|
||||
|
||||
Reference in new issue
Block a user