mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 18:29:05 +00:00
Implemented custom item rotation rate, and start using, using, stop using, finished using events for custom items.
This commit is contained in:
1 parent
11cc46b48f
commit
aab550cdca
7 files changed
+212
-36
No files matched your search
@@ -1,20 +1,23 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.ICustomItem;
|
||||
import noppes.npcs.scripted.interfaces.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
public class ItemEvent extends CustomNPCsEvent {
|
||||
public ScriptCustomItem item;
|
||||
public ICustomItem item;
|
||||
|
||||
public ItemEvent(ScriptCustomItem item) {
|
||||
public ItemEvent(ICustomItem item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public static class InitEvent extends ItemEvent {
|
||||
public InitEvent(ScriptCustomItem item) {
|
||||
public InitEvent(ICustomItem item) {
|
||||
super(item);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +25,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public static class UpdateEvent extends ItemEvent {
|
||||
public IEntity entity;
|
||||
|
||||
public UpdateEvent(ScriptCustomItem item, IEntity entity) {
|
||||
public UpdateEvent(ICustomItem item, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
@@ -33,7 +36,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public IEntity entity;
|
||||
public IPlayer player;
|
||||
|
||||
public TossedEvent(ScriptCustomItem item, IPlayer player, IEntity entity) {
|
||||
public TossedEvent(ICustomItem item, IPlayer player, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
this.player = player;
|
||||
@@ -43,7 +46,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public static class PickedUpEvent extends ItemEvent {
|
||||
public IPlayer player;
|
||||
|
||||
public PickedUpEvent(ScriptCustomItem item, IPlayer player) {
|
||||
public PickedUpEvent(ICustomItem item, IPlayer player) {
|
||||
super(item);
|
||||
this.player = player;
|
||||
}
|
||||
@@ -52,7 +55,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
@Cancelable
|
||||
public static class SpawnEvent extends ItemEvent {
|
||||
public IEntity entity;
|
||||
public SpawnEvent(ScriptCustomItem item, IEntity entity){
|
||||
public SpawnEvent(ICustomItem item, IEntity entity){
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
@@ -64,7 +67,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public final Object target;
|
||||
public IPlayer player;
|
||||
|
||||
public InteractEvent(ScriptCustomItem item, IPlayer player, int type, Object target) {
|
||||
public InteractEvent(ICustomItem item, IPlayer player, int type, Object target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -74,11 +77,11 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
|
||||
@Cancelable
|
||||
public static class AttackEvent extends ItemEvent {
|
||||
public final int type;//1: Hit, 2: Whiff //TODO: Implement type 2
|
||||
public final int type;//1: Hit, 2: Whiff
|
||||
public final Object target;
|
||||
public IEntity swingingEntity;
|
||||
|
||||
public AttackEvent(ScriptCustomItem item, IEntity swingingEntity, int type, Object target) {
|
||||
public AttackEvent(ICustomItem item, IEntity swingingEntity, int type, Object target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -86,4 +89,44 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartUsingItem extends ItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public StartUsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
public static class UsingItem extends ItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public UsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
public static class StopUsingItem extends ItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public StopUsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
public static class FinishUsingItem extends ItemEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public FinishUsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS
|
||||
public float translateX, translateY, translateZ;
|
||||
public float scaleX = 1.0F, scaleY = 1.0F, scaleZ = 1.0F;
|
||||
public float rotationX, rotationY, rotationZ;
|
||||
public float rotationXRate, rotationYRate, rotationZRate;
|
||||
|
||||
public ScriptCustomItem(ItemStack item) {
|
||||
super(item);
|
||||
@@ -273,6 +274,13 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationRate(float rotationXRate, float rotationYRate, float rotationZRate){
|
||||
this.rotationXRate = rotationXRate;
|
||||
this.rotationYRate = rotationYRate;
|
||||
this.rotationZRate = rotationZRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setScale(float scaleX, float scaleY, float scaleZ){
|
||||
this.scaleX = scaleX;
|
||||
this.scaleY = scaleY;
|
||||
@@ -302,6 +310,21 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationXRate(float rotationXRate) {
|
||||
this.rotationXRate = rotationXRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationYRate(float rotationYRate) {
|
||||
this.rotationYRate = rotationYRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationZRate(float rotationZRate) {
|
||||
this.rotationZRate = rotationZRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setScaleX(float scaleX) {
|
||||
this.scaleX = scaleX;
|
||||
saveItemData();
|
||||
@@ -344,6 +367,18 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS
|
||||
return rotationZ;
|
||||
}
|
||||
|
||||
public float getRotationXRate() {
|
||||
return rotationXRate;
|
||||
}
|
||||
|
||||
public float getRotationYRate() {
|
||||
return rotationYRate;
|
||||
}
|
||||
|
||||
public float getRotationZRate() {
|
||||
return rotationZRate;
|
||||
}
|
||||
|
||||
public float getScaleX() {
|
||||
return scaleX;
|
||||
}
|
||||
@@ -392,6 +427,10 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS
|
||||
compound.setFloat("RotationY",this.rotationY);
|
||||
compound.setFloat("RotationZ",this.rotationZ);
|
||||
|
||||
compound.setFloat("RotationXRate",this.rotationXRate);
|
||||
compound.setFloat("RotationYRate",this.rotationYRate);
|
||||
compound.setFloat("RotationZRate",this.rotationZRate);
|
||||
|
||||
compound.setFloat("ScaleX",this.scaleX);
|
||||
compound.setFloat("ScaleY",this.scaleY);
|
||||
compound.setFloat("ScaleZ",this.scaleZ);
|
||||
@@ -427,6 +466,10 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS
|
||||
this.rotationY = compound.getFloat("RotationY");
|
||||
this.rotationZ = compound.getFloat("RotationZ");
|
||||
|
||||
this.rotationXRate = compound.getFloat("RotationXRate");
|
||||
this.rotationYRate = compound.getFloat("RotationYRate");
|
||||
this.rotationZRate = compound.getFloat("RotationZRate");
|
||||
|
||||
this.scaleX = compound.getFloat("ScaleX");
|
||||
this.scaleY = compound.getFloat("ScaleY");
|
||||
this.scaleZ = compound.getFloat("ScaleZ");
|
||||
|
||||
Reference in new issue
Block a user