mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 13:25:10 +00:00
added attack speed parameter to linked Items
This commit is contained in:
1 parent
c3651fd6f7
commit
0b2bf5fd04
3 files changed
+37
-1
No files matched your search
@@ -51,6 +51,7 @@ import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
import noppes.npcs.controllers.data.LinkedItem;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
@@ -59,6 +60,7 @@ import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.QuestData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.items.ItemExcalibur;
|
||||
import noppes.npcs.items.ItemLinked;
|
||||
import noppes.npcs.items.ItemShield;
|
||||
import noppes.npcs.items.ItemSoulstoneEmpty;
|
||||
import noppes.npcs.quests.QuestKill;
|
||||
@@ -171,6 +173,19 @@ 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){
|
||||
int time = ep.getHeldItem().stackTagCompound.getCompoundTag("ItemData").getCompoundTag("LinkedData").getInteger("AttackSpeed");
|
||||
event.entity.hurtResistantTime = time;
|
||||
((EntityLivingBase) event.entity).hurtTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!(event.entityLiving instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
|
||||
@@ -115,13 +115,22 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
|
||||
y += spacing;
|
||||
|
||||
// Dig Speed field (0 to 20)
|
||||
addLabel(new GuiNpcLabel(11, "display.digSpeed", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
addLabel(new GuiNpcLabel(11, "Dig & Attack Speed", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
GuiNpcTextField digSpeedField = new GuiNpcTextField(12, this, x + 110, y, 50, 20, "" + linkedItem.digSpeed);
|
||||
digSpeedField.setIntegersOnly().setMinMaxDefault(0, 20, 1);
|
||||
addTextField(digSpeedField);
|
||||
GuiNpcTextField attackSpeedField = new GuiNpcTextField(14, this, x +165, y, 50, 20, "" +linkedItem.attackSpeed);
|
||||
attackSpeedField.setIntegersOnly().setMinMaxDefault(0,999999999,20);
|
||||
addTextField(attackSpeedField);
|
||||
|
||||
y += spacing;
|
||||
|
||||
// Attack Speed Field (integers only)
|
||||
//addLabel(new GuiNpcLabel(13,"Attack Speed",x,y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
|
||||
|
||||
//y += spacing;
|
||||
|
||||
// TEXTURE field
|
||||
addLabel(new GuiNpcLabel(3, "display.texture", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
addTextField(new GuiNpcTextField(2, this, x + 60, y, 200, 20, linkedItem.display.texture));
|
||||
@@ -401,6 +410,9 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
|
||||
} else if (id == 12) {
|
||||
// Dig Speed
|
||||
linkedItem.digSpeed = textField.getInteger();
|
||||
} else if (id == 14) {
|
||||
// attack Speed
|
||||
linkedItem.attackSpeed = textField.getInteger();
|
||||
} else if (id == 31) {
|
||||
linkedItem.display.scaleX = textField.getFloat();
|
||||
} else if (id == 32) {
|
||||
|
||||
@@ -29,6 +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 armorType = -2; //-2: Fits in no armor slot, -1: Fits in all slots, 0 - 3: Fits in Head -> Boots slot respectively
|
||||
public int enchantability;
|
||||
|
||||
@@ -58,6 +59,7 @@ 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("ArmorType", this.armorType);
|
||||
compound.setInteger("Enchantability", this.enchantability);
|
||||
|
||||
@@ -87,6 +89,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.armorType = compound.getInteger("ArmorType");
|
||||
this.enchantability = compound.getInteger("Enchantability");
|
||||
|
||||
@@ -251,4 +254,10 @@ 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;}
|
||||
}
|
||||
Reference in new issue
Block a user