Skip to content
Permalink
Browse files

add getHeldItem helper utility

  • Loading branch information...
mcmonkey4eva committed Oct 12, 2018
1 parent ae95341 commit 0cabe66dd339b9d01b3750d7ea00c6e6c3df087c
@@ -3,7 +3,7 @@ Sentinel NPCs: Combat NPCs for Spigot!

![AnimatedSentinel](http://i.imgur.com/VDwTzrs.gif)

**Version 1.7.1**: Compatible with Spigot 1.8.8(see Info section below), 1.9.4, 1.10.2, 1.11.2, 1.12.2, and 1.13.1
**Version 1.7.2**: Compatible with Spigot 1.8.8(see Info section below), 1.9.4, 1.10.2, 1.11.2, 1.12.2, and 1.13.1

### Downloads

@@ -7,7 +7,7 @@
<groupId>org.mcmonkey</groupId>
<artifactId>sentinel</artifactId>
<packaging>jar</packaging>
<version>1.7.1</version>
<version>1.7.2</version>
<name>Sentinel</name>
<description>Combat NPCs for Spigot</description>

@@ -272,12 +272,7 @@ public ItemStack getHeldItem() {
return null;
}
// TODO: Just only use this (instead of Inventory trait)?
if (SentinelTarget.v1_9) {
return getLivingEntity().getEquipment().getItemInMainHand();
}
else {
return getLivingEntity().getEquipment().getItemInHand();
}
return SentinelUtilities.getHeldItem(getLivingEntity());
}
return getNPC().getTrait(Inventory.class).getContents()[0];
}
@@ -29,6 +29,18 @@
*/
public static Random random = new Random();

/**
* Returns the item held in an entity's hand.
*/
public static ItemStack getHeldItem(LivingEntity entity) {
if (SentinelTarget.v1_9) {
return entity.getEquipment().getItemInMainHand();
}
else {
return entity.getEquipment().getItemInHand();
}
}

/**
* Traces a ray from a start to an end, returning the end of the ray (stopped early if there are solid blocks in the way).
*/

0 comments on commit 0cabe66

Please sign in to comment.
You can’t perform that action at this time.