mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 10:06:00 +00:00
Merge branch 'dev' into dev
This commit is contained in:
799 files changed
+49724
-13791
No files matched your search
@@ -0,0 +1,108 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import noppes.npcs.api.entity.IAnimatable;
|
||||
import noppes.npcs.api.event.IAnimationEvent;
|
||||
import noppes.npcs.api.handler.data.IAnimation;
|
||||
import noppes.npcs.api.handler.data.IAnimationData;
|
||||
import noppes.npcs.api.handler.data.IFrame;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
|
||||
public abstract class AnimationEvent extends CustomNPCsEvent implements IAnimationEvent {
|
||||
protected final IAnimation animation;
|
||||
protected final IAnimationData animationData;
|
||||
protected final IAnimatable entity;
|
||||
|
||||
public AnimationEvent(IAnimation animation) {
|
||||
this.animation = animation;
|
||||
this.animationData = animation.getParent();
|
||||
this.entity = this.animationData.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnimation getAnimation() {
|
||||
return this.animation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnimationData getAnimationData() {
|
||||
return this.animationData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnimatable getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Started extends AnimationEvent {
|
||||
|
||||
public Started(IAnimation animation) {
|
||||
super(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.ANIMATION_START.function;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Ended extends AnimationEvent {
|
||||
|
||||
public Ended(IAnimation animation) {
|
||||
super(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.ANIMATION_END.function;
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class FrameEvent extends AnimationEvent implements IFrameEvent {
|
||||
private final IFrame frame;
|
||||
private final int index;
|
||||
|
||||
public FrameEvent(IAnimation animation, IFrame frame) {
|
||||
super(animation);
|
||||
this.frame = frame;
|
||||
this.index = ((Animation)this.getAnimation()).frames.indexOf((Frame) this.frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFrame getFrame() {
|
||||
return this.frame;
|
||||
}
|
||||
|
||||
public static class Entered extends FrameEvent {
|
||||
|
||||
public Entered(IAnimation animation, IFrame frame) {
|
||||
super(animation, frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.ANIMATION_FRAME_ENTER.function;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Exited extends FrameEvent {
|
||||
|
||||
public Exited(IAnimation animation, IFrame frame) {
|
||||
super(animation, frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.ANIMATION_FRAME_EXIT.function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,18 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.event.IItemEvent;
|
||||
import noppes.npcs.api.item.IItemCustom;
|
||||
import noppes.npcs.api.item.IItemCustomizable;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
|
||||
public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IItemCustom item;
|
||||
public final IItemCustomizable item;
|
||||
|
||||
public ItemEvent(IItemCustom item) {
|
||||
public ItemEvent(IItemCustomizable item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public IItemCustom getItem() {
|
||||
public IItemCustomizable getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
}
|
||||
|
||||
public static class InitEvent extends ItemEvent implements IItemEvent.InitEvent {
|
||||
public InitEvent(IItemCustom item) {
|
||||
public InitEvent(IItemCustomizable item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public static class UpdateEvent extends ItemEvent implements IItemEvent.UpdateEvent {
|
||||
public final IEntity entity;
|
||||
|
||||
public UpdateEvent(IItemCustom item, IEntity entity) {
|
||||
public UpdateEvent(IItemCustomizable item, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
@@ -54,7 +55,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IEntity entity;
|
||||
public final IPlayer player;
|
||||
|
||||
public TossedEvent(IItemCustom item, IPlayer player, IEntity entity) {
|
||||
public TossedEvent(IItemCustomizable item, IPlayer player, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
this.player = player;
|
||||
@@ -76,7 +77,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public static class PickedUpEvent extends ItemEvent implements IItemEvent.PickedUpEvent {
|
||||
public final IPlayer player;
|
||||
|
||||
public PickedUpEvent(IItemCustom item, IPlayer player) {
|
||||
public PickedUpEvent(IItemCustomizable item, IPlayer player) {
|
||||
super(item);
|
||||
this.player = player;
|
||||
}
|
||||
@@ -94,7 +95,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public static class SpawnEvent extends ItemEvent implements IItemEvent.SpawnEvent {
|
||||
public final IEntity entity;
|
||||
|
||||
public SpawnEvent(IItemCustom item, IEntity entity){
|
||||
public SpawnEvent(IItemCustomizable item, IEntity entity){
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IEntity target;
|
||||
public final IPlayer player;
|
||||
|
||||
public InteractEvent(IItemCustom item, IPlayer player, int type, IEntity target) {
|
||||
public InteractEvent(IItemCustomizable item, IPlayer player, int type, IEntity target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -148,7 +149,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final Object target;
|
||||
public final IPlayer player;
|
||||
|
||||
public RightClickEvent(IItemCustom item, IPlayer player, int type, Object target) {
|
||||
public RightClickEvent(IItemCustomizable item, IPlayer player, int type, Object target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -178,7 +179,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IEntity target;
|
||||
public final IEntity swingingEntity;
|
||||
|
||||
public AttackEvent(IItemCustom item, IEntity swingingEntity, int type, IEntity target) {
|
||||
public AttackEvent(IItemCustomizable item, IEntity swingingEntity, int type, IEntity target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -207,7 +208,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public StartUsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
public StartUsingItem(IItemCustomizable item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
@@ -231,7 +232,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public UsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
public UsingItem(IItemCustomizable item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
@@ -255,7 +256,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public StopUsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
public StopUsingItem(IItemCustomizable item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
@@ -279,7 +280,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public FinishUsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
public FinishUsingItem(IItemCustomizable item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
@@ -297,4 +298,69 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BreakItem extends ItemEvent implements IItemEvent.BreakItem {
|
||||
public final IPlayer player;
|
||||
|
||||
public BreakItem(IItemCustomizable item, IPlayer player) {
|
||||
super(item);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.BREAK_ITEM.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack getBrokenStack() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RepairItem extends ItemEvent implements IItemEvent.RepairItem {
|
||||
public final IPlayer player;
|
||||
public final IItemStack left, right;
|
||||
public final float anvilBreakChance;
|
||||
|
||||
public RepairItem(IItemCustomizable item, IPlayer player, IItemStack left, IItemStack right, float anvilBreakChance) {
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
this.anvilBreakChance = anvilBreakChance;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.REPAIR_ITEM.function;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack getRight() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack getOutput() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnvilBreakChance() {
|
||||
return this.anvilBreakChance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import noppes.npcs.api.event.ILinkedItemEvent;
|
||||
import noppes.npcs.api.item.IItemLinked;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
|
||||
public class LinkedItemEvent extends ItemEvent implements ILinkedItemEvent {
|
||||
|
||||
public LinkedItemEvent(IItemLinked item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
public static class VersionChangeEvent extends ItemEvent implements ILinkedItemEvent.VersionChangeEvent {
|
||||
public final int version, prevVersion;
|
||||
|
||||
public VersionChangeEvent(IItemLinked item, int version, int prevVersion) {
|
||||
super(item);
|
||||
this.version = version;
|
||||
this.prevVersion = prevVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreviousVersion() {
|
||||
return this.prevVersion;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.LINKED_ITEM_VERSION.function;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BuildEvent extends ItemEvent implements ILinkedItemEvent.BuildEvent {
|
||||
public BuildEvent(IItemLinked item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.LINKED_ITEM_BUILD.function;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IEntityLivingBase;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.event.IPlayerEvent;
|
||||
import noppes.npcs.api.handler.data.IPlayerEffect;
|
||||
import noppes.npcs.api.handler.data.IProfile;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
@@ -949,4 +951,128 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
|
||||
return EnumScriptType.RANGED_LAUNCHED.function;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EffectEvent extends PlayerEvent implements IPlayerEvent.EffectEvent {
|
||||
|
||||
public final IPlayerEffect effect;
|
||||
|
||||
public EffectEvent(IPlayer player, IPlayerEffect statusEffect) {
|
||||
super(player);
|
||||
this.effect = statusEffect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerEffect getEffect() {
|
||||
return this.effect;
|
||||
}
|
||||
|
||||
public static class Added extends PlayerEvent.EffectEvent implements IPlayerEvent.EffectEvent.Added {
|
||||
|
||||
public Added(IPlayer player, IPlayerEffect statusEffect) {
|
||||
super(player, statusEffect);
|
||||
}
|
||||
|
||||
}
|
||||
public static class Ticked extends PlayerEvent.EffectEvent implements IPlayerEvent.EffectEvent.Ticked {
|
||||
|
||||
public Ticked(IPlayer player, IPlayerEffect statusEffect) {
|
||||
super(player, statusEffect);
|
||||
}
|
||||
|
||||
}
|
||||
public static class Removed extends PlayerEvent.EffectEvent implements IPlayerEvent.EffectEvent.Removed {
|
||||
|
||||
private final ExpirationType type;
|
||||
|
||||
public Removed(IPlayer player, IPlayerEffect statusEffect, ExpirationType type) {
|
||||
super(player, statusEffect);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTimerRunOut() {
|
||||
return type == ExpirationType.RUN_OUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causedByDeath() {
|
||||
return type == ExpirationType.DEATH;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ExpirationType {
|
||||
REMOVED,
|
||||
RUN_OUT,
|
||||
DEATH
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ProfileEvent extends PlayerEvent implements IPlayerEvent.ProfileEvent {
|
||||
public final IProfile profile;
|
||||
public final int slot;
|
||||
|
||||
public ProfileEvent(IPlayer player, IProfile profile, int slot) {
|
||||
super(player);
|
||||
this.profile = profile;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProfile getProfile() {
|
||||
return this.profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Changed extends PlayerEvent.ProfileEvent implements IPlayerEvent.ProfileEvent.Changed {
|
||||
public final int prevSlot;
|
||||
|
||||
public Changed(IPlayer player, IProfile profile, int slot, int prevSlot) {
|
||||
super(player, profile, slot);
|
||||
this.prevSlot = prevSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevSlot() {
|
||||
return this.prevSlot;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE_CHANGE.function;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Removed extends PlayerEvent.ProfileEvent implements IPlayerEvent.ProfileEvent.Removed {
|
||||
|
||||
public Removed(IPlayer player, IProfile profile, int slot) {
|
||||
super(player, profile, slot);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE_REMOVE.function;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Create extends PlayerEvent.ProfileEvent implements IPlayerEvent.ProfileEvent.Create {
|
||||
|
||||
public Create(IPlayer player, IProfile profile, int slot) {
|
||||
super(player, profile, slot);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE_CREATE.function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user