2022-05-11 01:10:31 -05:00
|
|
|
package noppes.npcs.scripted.event;
|
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
2022-11-15 15:25:53 -05:00
|
|
|
import noppes.npcs.api.entity.IEntity;
|
|
|
|
|
import noppes.npcs.api.entity.IPlayer;
|
2023-01-12 21:33:06 -05:00
|
|
|
import noppes.npcs.api.event.IItemEvent;
|
2025-02-13 19:00:21 -06:00
|
|
|
import noppes.npcs.api.item.IItemCustomizable;
|
2022-11-24 16:46:20 -06:00
|
|
|
import noppes.npcs.constants.EnumScriptType;
|
2022-05-11 01:10:31 -05:00
|
|
|
|
2024-08-22 16:47:45 -04:00
|
|
|
public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
2025-02-13 19:00:21 -06:00
|
|
|
public final IItemCustomizable item;
|
2022-05-11 01:10:31 -05:00
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public ItemEvent(IItemCustomizable item) {
|
2022-05-11 01:10:31 -05:00
|
|
|
this.item = item;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public IItemCustomizable getItem() {
|
2022-11-24 14:36:09 -06:00
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.CUSTOM_ITEM_EVENT.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class InitEvent extends ItemEvent implements IItemEvent.InitEvent {
|
2025-02-13 19:00:21 -06:00
|
|
|
public InitEvent(IItemCustomizable item) {
|
2022-05-11 01:10:31 -05:00
|
|
|
super(item);
|
|
|
|
|
}
|
2022-11-24 16:46:20 -06:00
|
|
|
|
|
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.INIT.function;
|
|
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class UpdateEvent extends ItemEvent implements IItemEvent.UpdateEvent {
|
|
|
|
|
public final IEntity entity;
|
2022-05-11 01:10:31 -05:00
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public UpdateEvent(IItemCustomizable item, IEntity entity) {
|
2022-05-11 01:10:31 -05:00
|
|
|
super(item);
|
2022-05-11 13:30:13 -05:00
|
|
|
this.entity = entity;
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.TICK.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IEntity getEntity() {
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class TossedEvent extends ItemEvent implements IItemEvent.TossedEvent {
|
|
|
|
|
public final IEntity entity;
|
|
|
|
|
public final IPlayer player;
|
2022-05-11 01:10:31 -05:00
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public TossedEvent(IItemCustomizable item, IPlayer player, IEntity entity) {
|
2022-05-11 01:10:31 -05:00
|
|
|
super(item);
|
|
|
|
|
this.entity = entity;
|
|
|
|
|
this.player = player;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.TOSSED.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IEntity getEntity() {
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class PickedUpEvent extends ItemEvent implements IItemEvent.PickedUpEvent {
|
|
|
|
|
public final IPlayer player;
|
2022-05-11 01:10:31 -05:00
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public PickedUpEvent(IItemCustomizable item, IPlayer player) {
|
2022-05-11 01:10:31 -05:00
|
|
|
super(item);
|
|
|
|
|
this.player = player;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.PICKEDUP.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class SpawnEvent extends ItemEvent implements IItemEvent.SpawnEvent {
|
|
|
|
|
public final IEntity entity;
|
|
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public SpawnEvent(IItemCustomizable item, IEntity entity){
|
2022-05-11 01:10:31 -05:00
|
|
|
super(item);
|
|
|
|
|
this.entity = entity;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.SPAWN.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IEntity getEntity() {
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class InteractEvent extends ItemEvent implements IItemEvent.InteractEvent {
|
2022-05-11 01:10:31 -05:00
|
|
|
public final int type;
|
2022-11-24 14:36:09 -06:00
|
|
|
public final IEntity target;
|
|
|
|
|
public final IPlayer player;
|
2022-05-11 01:10:31 -05:00
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public InteractEvent(IItemCustomizable item, IPlayer player, int type, IEntity target) {
|
2022-05-11 01:10:31 -05:00
|
|
|
super(item);
|
|
|
|
|
this.type = type;
|
|
|
|
|
this.target = target;
|
|
|
|
|
this.player = player;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.INTERACT.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public int getType() {
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEntity getTarget() {
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
|
|
|
|
|
2024-02-21 00:31:17 -05:00
|
|
|
@Cancelable
|
|
|
|
|
public static class RightClickEvent extends ItemEvent implements IItemEvent.RightClickEvent {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 0:air, 1:entity, 2:block
|
|
|
|
|
*/
|
|
|
|
|
public final int type;
|
|
|
|
|
public final Object target;
|
|
|
|
|
public final IPlayer player;
|
|
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public RightClickEvent(IItemCustomizable item, IPlayer player, int type, Object target) {
|
2024-02-21 00:31:17 -05:00
|
|
|
super(item);
|
|
|
|
|
this.type = type;
|
|
|
|
|
this.target = target;
|
|
|
|
|
this.player = player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getHookName() {
|
2024-03-28 03:15:19 -04:00
|
|
|
return EnumScriptType.RIGHT_CLICK.function;
|
2024-02-21 00:31:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getType() {
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object getTarget() {
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-11 01:10:31 -05:00
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class AttackEvent extends ItemEvent implements IItemEvent.AttackEvent {
|
2022-05-11 14:24:12 -05:00
|
|
|
public final int type;//1: Hit, 2: Whiff
|
2022-11-24 14:36:09 -06:00
|
|
|
public final IEntity target;
|
|
|
|
|
public final IEntity swingingEntity;
|
2022-05-11 01:10:31 -05:00
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public AttackEvent(IItemCustomizable item, IEntity swingingEntity, int type, IEntity target) {
|
2022-05-11 01:10:31 -05:00
|
|
|
super(item);
|
|
|
|
|
this.type = type;
|
|
|
|
|
this.target = target;
|
2022-05-11 13:30:13 -05:00
|
|
|
this.swingingEntity = swingingEntity;
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.ATTACK.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public int getType() {
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEntity getTarget() {
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEntity getSwingingEntity() {
|
|
|
|
|
return swingingEntity;
|
|
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|
|
|
|
|
|
2023-01-25 21:54:25 -06:00
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class StartUsingItem extends ItemEvent implements IItemEvent.StartUsingItem {
|
2022-05-11 14:24:12 -05:00
|
|
|
public final IPlayer player;
|
|
|
|
|
public final int duration;
|
|
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public StartUsingItem(IItemCustomizable item, IPlayer player, int duration){
|
2022-05-11 14:24:12 -05:00
|
|
|
super(item);
|
|
|
|
|
this.player = player;
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.START_USING_ITEM.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDuration() {
|
|
|
|
|
return duration;
|
|
|
|
|
}
|
2022-05-11 14:24:12 -05:00
|
|
|
}
|
2023-01-25 21:54:25 -06:00
|
|
|
|
|
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class UsingItem extends ItemEvent implements IItemEvent.UsingItem {
|
2022-05-11 14:24:12 -05:00
|
|
|
public final IPlayer player;
|
|
|
|
|
public final int duration;
|
|
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public UsingItem(IItemCustomizable item, IPlayer player, int duration){
|
2022-05-11 14:24:12 -05:00
|
|
|
super(item);
|
|
|
|
|
this.player = player;
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.USING_ITEM.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDuration() {
|
|
|
|
|
return duration;
|
|
|
|
|
}
|
2022-05-11 14:24:12 -05:00
|
|
|
}
|
2023-01-25 21:54:25 -06:00
|
|
|
|
|
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class StopUsingItem extends ItemEvent implements IItemEvent.StopUsingItem {
|
2022-05-11 14:24:12 -05:00
|
|
|
public final IPlayer player;
|
|
|
|
|
public final int duration;
|
|
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public StopUsingItem(IItemCustomizable item, IPlayer player, int duration){
|
2022-05-11 14:24:12 -05:00
|
|
|
super(item);
|
|
|
|
|
this.player = player;
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.STOP_USING_ITEM.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDuration() {
|
|
|
|
|
return duration;
|
|
|
|
|
}
|
2022-05-11 14:24:12 -05:00
|
|
|
}
|
2023-01-25 21:54:25 -06:00
|
|
|
|
|
|
|
|
@Cancelable
|
2022-11-24 14:36:09 -06:00
|
|
|
public static class FinishUsingItem extends ItemEvent implements IItemEvent.FinishUsingItem {
|
2022-05-11 14:24:12 -05:00
|
|
|
public final IPlayer player;
|
|
|
|
|
public final int duration;
|
|
|
|
|
|
2025-02-13 19:00:21 -06:00
|
|
|
public FinishUsingItem(IItemCustomizable item, IPlayer player, int duration){
|
2022-05-11 14:24:12 -05:00
|
|
|
super(item);
|
|
|
|
|
this.player = player;
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
}
|
2022-11-24 14:36:09 -06:00
|
|
|
|
2022-11-24 16:46:20 -06:00
|
|
|
public String getHookName() {
|
|
|
|
|
return EnumScriptType.FINISH_USING_ITEM.function;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:36:09 -06:00
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDuration() {
|
|
|
|
|
return duration;
|
|
|
|
|
}
|
2022-05-11 14:24:12 -05:00
|
|
|
}
|
2022-05-11 01:10:31 -05:00
|
|
|
}
|