Add AltarCraftedEvent
Called after an altar has crafted an item. Not cancellable, however the output itemstack may be modified.
This commit is contained in:
parent
45710ebb8f
commit
7af53ce85b
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.altar;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.event.AltarCraftedEvent;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -10,6 +11,7 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumParticleTypes;
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
@ -73,6 +75,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
|
|
||||||
private int cooldownAfterCrafting = 60;
|
private int cooldownAfterCrafting = 60;
|
||||||
|
|
||||||
|
private AltarRecipe recipe;
|
||||||
private ItemStack result;
|
private ItemStack result;
|
||||||
|
|
||||||
public BloodAltar(TileAltar tileAltar)
|
public BloodAltar(TileAltar tileAltar)
|
||||||
|
@ -311,6 +314,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
if (recipe.doesRequiredItemMatch(tileAltar.getStackInSlot(0), altarTier))
|
if (recipe.doesRequiredItemMatch(tileAltar.getStackInSlot(0), altarTier))
|
||||||
{
|
{
|
||||||
this.isActive = true;
|
this.isActive = true;
|
||||||
|
this.recipe = recipe;
|
||||||
this.result = recipe.getOutput() == null ? null : new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata());
|
this.result = recipe.getOutput() == null ? null : new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata());
|
||||||
this.liquidRequired = recipe.getSyphon();
|
this.liquidRequired = recipe.getSyphon();
|
||||||
this.canBeFilled = recipe.isFillable();
|
this.canBeFilled = recipe.isFillable();
|
||||||
|
@ -448,6 +452,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
if (result != null)
|
if (result != null)
|
||||||
result.stackSize *= stackSize;
|
result.stackSize *= stackSize;
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.post(new AltarCraftedEvent(recipe, result));
|
||||||
tileAltar.setInventorySlotContents(0, result);
|
tileAltar.setInventorySlotContents(0, result);
|
||||||
progress = 0;
|
progress = 0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package WayofTime.bloodmagic.api.event;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired whenever a craft is completed in a BloodAltar.
|
||||||
|
*
|
||||||
|
* It is not cancelable, however you can modify the output stack.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class AltarCraftedEvent extends Event
|
||||||
|
{
|
||||||
|
|
||||||
|
private final AltarRecipeRegistry.AltarRecipe altarRecipe;
|
||||||
|
private final ItemStack output;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param altarRecipe
|
||||||
|
* - The recipe that was crafted.
|
||||||
|
* @param output
|
||||||
|
* - The item obtained from the recipe
|
||||||
|
*/
|
||||||
|
public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output)
|
||||||
|
{
|
||||||
|
this.altarRecipe = altarRecipe;
|
||||||
|
this.output = output;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue