mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 15:45:10 +00:00
Add some more Attack Speed Handling
This commit is contained in:
1 parent
8dad290486
commit
592a910cbc
6 files changed
+39
-14
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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;}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user