ForgePatch/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java

109 lines
3.5 KiB
Java

/*
* Minecraft Forge
* Copyright (c) 2016.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.brewing;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityBrewingStand;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import javax.annotation.Nonnull;
public class PotionBrewEvent extends Event
{
private NonNullList<ItemStack> stacks;
protected PotionBrewEvent(NonNullList<ItemStack> stacks)
{
this.stacks = stacks;
}
@Nonnull
public ItemStack getItem(int index)
{
if (index >= stacks.size()) return ItemStack.EMPTY;
return stacks.get(index);
}
public void setItem(int index, @Nonnull ItemStack stack)
{
if (index < stacks.size())
{
stacks.set(index, stack);
}
}
public int getLength()
{
return stacks.size();
}
/**
* PotionBrewEvent.Pre is fired before vanilla brewing takes place.
* All changes made to the event's array will be made to the TileEntity if the event is canceled.
* <br>
* The event is fired during the {@link TileEntityBrewingStand#brewPotions()} method invocation.<br>
* <br>
* {@link #stacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If the event is not canceled, the vanilla brewing will take place instead of modded brewing.
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
* <br>
* If this event is canceled, and items have been modified, PotionBrewEvent.Post will automatically be fired.
**/
@Cancelable
public static class Pre extends PotionBrewEvent
{
public Pre(NonNullList<ItemStack> stacks)
{
super(stacks);
}
}
/**
* PotionBrewEvent.Post is fired when a potion is brewed in the brewing stand.
* <br>
* The event is fired during the {@link TileEntityBrewingStand#brewPotions()} method invocation.<br>
* <br>
* {@link #stacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class Post extends PotionBrewEvent
{
public Post(NonNullList<ItemStack> stacks)
{
super(stacks);
}
}
}