diff --git a/src/api b/src/api index 305a3778c..d003d6d87 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit 305a3778c86fed2680b8cad173b7e5fb0f3c98e6 +Subproject commit d003d6d870db13d56fce223050a06faf15050eae diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java index 1bd184a4a..eab17aff1 100644 --- a/src/main/java/noppes/npcs/ServerEventsHandler.java +++ b/src/main/java/noppes/npcs/ServerEventsHandler.java @@ -173,9 +173,6 @@ public class ServerEventsHandler { @SubscribeEvent public void invoke(LivingHurtEvent event) { - - - if(event.source.getEntity() instanceof EntityPlayerMP && event.entity instanceof EntityLivingBase ){ EntityPlayerMP ep = (EntityPlayerMP) event.source.getEntity(); if(ep.getHeldItem() != null && ep.getHeldItem().getItem() instanceof ItemLinked){ @@ -185,7 +182,6 @@ public class ServerEventsHandler { } } - if (!(event.entityLiving instanceof EntityPlayer)) return; diff --git a/src/main/java/noppes/npcs/controllers/data/LinkedItem.java b/src/main/java/noppes/npcs/controllers/data/LinkedItem.java index 4fb5fc6e7..f1840a625 100644 --- a/src/main/java/noppes/npcs/controllers/data/LinkedItem.java +++ b/src/main/java/noppes/npcs/controllers/data/LinkedItem.java @@ -29,7 +29,7 @@ public class LinkedItem implements ILinkedItem { public boolean isNormalItem = false; public boolean isTool = false; public int digSpeed = 1; - public int attackSpeed = 20; + public int attackSpeed = 10; public int armorType = -2; //-2: Fits in no armor slot, -1: Fits in all slots, 0 - 3: Fits in Head -> Boots slot respectively public int enchantability; @@ -59,7 +59,8 @@ public class LinkedItem implements ILinkedItem { compound.setBoolean("IsTool", this.isTool); compound.setBoolean("IsNormalItem", this.isNormalItem); compound.setInteger("DigSpeed", this.digSpeed); - compound.setInteger("AttackSpeed",this.attackSpeed); + compound.setInteger("AttackSpeed", this.attackSpeed); + compound.setInteger("ArmorType", this.armorType); compound.setInteger("Enchantability", this.enchantability); @@ -89,7 +90,7 @@ public class LinkedItem implements ILinkedItem { this.isTool = compound.getBoolean("IsTool"); this.isNormalItem = compound.getBoolean("IsNormalItem"); this.digSpeed = compound.getInteger("DigSpeed"); - this.attackSpeed = compound.getInteger("AttackSpeed"); + this.setAttackSpeed(compound.getInteger("AttackSpeed")); this.armorType = compound.getInteger("ArmorType"); this.enchantability = compound.getInteger("Enchantability"); @@ -241,6 +242,19 @@ public class LinkedItem implements ILinkedItem { this.enchantability = enchantability; } + @Override + public int getAttackSpeed() { + return attackSpeed; + } + + @Override + public void setAttackSpeed(int time) { + if(time <= 0) { + time = 10; + } + this.attackSpeed = time; + } + public LinkedItem clone() { NBTTagCompound nbt = this.writeToNBT(true); LinkedItem clone = new LinkedItem(this.name); @@ -254,10 +268,4 @@ public class LinkedItem implements ILinkedItem { setScriptHandler(data = new LinkedItemScript()); return data; } - - @Override - public int getAttackSpeed() {return attackSpeed;} - - @Override - public void setAttackSpeed(int time) {this.attackSpeed = time;} } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index 0103a9af2..6e85e1555 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -36,6 +36,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus public int digSpeed = 1; public int armorType = -2; //-2: Fits in no armor slot, -1: Fits in all slots, 0 - 4: Fits in Head -> Boots slot respectively public int enchantability; + public int attackSpeed = 10; public long lastInited = -1; @@ -228,6 +229,18 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus return this.enchantability; } + public int getAttackSpeed() { + return this.attackSpeed; + } + + public void setAttackSpeed(int speed) { + if(speed <= 0) { + speed = 10; + } + this.attackSpeed = speed; + saveItemData(); + } + public void setEnchantability(int enchantability) { this.enchantability = enchantability; saveItemData(); @@ -270,6 +283,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus compound.setInteger("DigSpeed", this.digSpeed); compound.setInteger("ArmorType", this.armorType); compound.setInteger("Enchantability", this.enchantability); + compound.setInteger("AttackSpeed", this.attackSpeed); compound.setInteger("MaxItemUseDuration", this.maxItemUseDuration); compound.setInteger("ItemUseAction", this.itemUseAction); @@ -286,6 +300,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus this.digSpeed = compound.getInteger("DigSpeed"); this.armorType = compound.getInteger("ArmorType"); this.enchantability = compound.getInteger("Enchantability"); + setAttackSpeed(compound.getInteger("AttackSpeed")); this.maxItemUseDuration = compound.getInteger("MaxItemUseDuration"); this.itemUseAction = compound.getInteger("ItemUseAction"); diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java index 224427c12..77e51df2c 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java @@ -30,6 +30,7 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements public abstract int getEnchantability(); + public abstract int getAttackSpeed(); public String getTexture() { return this.itemDisplay.texture == null ? "" : this.itemDisplay.texture; diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java index 6e5e10b76..3a777134c 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java @@ -102,6 +102,11 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin return this.linkedItem.enchantability; } + @Override + public int getAttackSpeed() { + return this.linkedItem.attackSpeed; + } + @Override public String getTexture() { return this.itemDisplay.texture == null ? this.linkedItem.display.texture : this.itemDisplay.texture;