2016-03-02 04:42:36 +00:00
|
|
|
package net.minecraftforge.event.entity.living;
|
2014-01-25 03:10:51 +00:00
|
|
|
|
2016-03-02 04:42:36 +00:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2014-01-25 03:10:51 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-03-23 14:34:48 +00:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
2014-01-25 03:10:51 +00:00
|
|
|
|
2016-03-02 04:42:36 +00:00
|
|
|
public abstract class LivingEntityUseItemEvent extends LivingEvent
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
|
|
|
public final ItemStack item;
|
|
|
|
public int duration;
|
|
|
|
|
2016-03-02 04:42:36 +00:00
|
|
|
private LivingEntityUseItemEvent(EntityLivingBase entity, ItemStack item, int duration)
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
super(entity);
|
2014-01-25 03:10:51 +00:00
|
|
|
this.item = item;
|
|
|
|
this.duration = duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fired when a player starts 'using' an item, typically when they hold right mouse.
|
|
|
|
* Examples:
|
|
|
|
* Drawing a bow
|
|
|
|
* Eating Food
|
|
|
|
* Drinking Potions/Milk
|
|
|
|
* Guarding with a sword
|
|
|
|
*
|
|
|
|
* Cancel the event, or set the duration or <= 0 to prevent it from processing.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2016-03-02 04:42:36 +00:00
|
|
|
public static class Start extends LivingEntityUseItemEvent
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
public Start(EntityLivingBase entity, ItemStack item, int duration)
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
super(entity, item, duration);
|
2014-01-25 03:10:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fired every tick that a player is 'using' an item, see {@link Start} for info.
|
|
|
|
*
|
|
|
|
* Cancel the event, or set the duration or <= 0 to cause the player to stop using the item.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2016-03-02 04:42:36 +00:00
|
|
|
public static class Tick extends LivingEntityUseItemEvent
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
public Tick(EntityLivingBase entity, ItemStack item, int duration)
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
super(entity, item, duration);
|
2014-01-25 03:10:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-02 04:42:36 +00:00
|
|
|
* Fired when a player stops using an item without the use duration timing out.
|
2014-01-25 03:10:51 +00:00
|
|
|
* Example:
|
|
|
|
* Stop eating 1/2 way through
|
|
|
|
* Stop defending with sword
|
|
|
|
* Stop drawing bow. This case would fire the arrow
|
2016-03-02 04:42:36 +00:00
|
|
|
*
|
2014-01-25 03:10:51 +00:00
|
|
|
* Duration on this event is how long the item had left in it's count down before 'finishing'
|
|
|
|
*
|
2016-03-02 04:42:36 +00:00
|
|
|
* Canceling this event will prevent the Item from being notified that it has stopped being used,
|
2014-01-25 03:10:51 +00:00
|
|
|
* The only vanilla item this would effect are bows, and it would cause them NOT to fire there arrow.
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2016-03-02 04:42:36 +00:00
|
|
|
public static class Stop extends LivingEntityUseItemEvent
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
public Stop(EntityLivingBase entity, ItemStack item, int duration)
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
super(entity, item, duration);
|
2014-01-25 03:10:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fired after an item has fully finished being used.
|
|
|
|
* The item has been notified that it was used, and the item/result stacks reflect after that state.
|
|
|
|
* This means that when this is fired for a Potion, the potion effect has already been applied.
|
2016-03-02 04:42:36 +00:00
|
|
|
*
|
2014-01-25 03:10:51 +00:00
|
|
|
* If you wish to cancel those effects, you should cancel one of the above events.
|
2016-03-02 04:42:36 +00:00
|
|
|
*
|
2014-01-25 03:10:51 +00:00
|
|
|
* The result item stack is the stack that is placed in the player's inventory in replacement of the stack that is currently being used.
|
|
|
|
*
|
|
|
|
*/
|
2016-03-02 04:42:36 +00:00
|
|
|
public static class Finish extends LivingEntityUseItemEvent
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
|
|
|
public ItemStack result;
|
2016-03-02 04:42:36 +00:00
|
|
|
public Finish(EntityLivingBase entity, ItemStack item, int duration, ItemStack result)
|
2014-01-25 03:10:51 +00:00
|
|
|
{
|
2016-03-02 04:42:36 +00:00
|
|
|
super(entity, item, duration);
|
2014-01-25 03:10:51 +00:00
|
|
|
this.result = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|