Skip to content

Commit

Permalink
Add "offhand" to EquipCommand, fixes #1334
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Mar 11, 2016
1 parent b94cab0 commit 24cb66a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -989,7 +989,7 @@ public void registerCoreMembers() {

// <--[command]
// @Name Equip
// @Syntax equip (<entity>|...) (hand:<item>) (head:<item>) (chest:<item>) (legs:<item>) (boots:<item>) (saddle:<item>) (horse_armor:<item>)
// @Syntax equip (<entity>|...) (hand:<item>) (offhand:<item>) (head:<item>) (chest:<item>) (legs:<item>) (boots:<item>) (saddle:<item>) (horse_armor:<item>)
// @Required 1
// @Stable stable
// @Short Equips items and armor on a list of entities.
Expand Down Expand Up @@ -1017,7 +1017,7 @@ public void registerCoreMembers() {
// - equip e@pig saddle:i@saddle
// -->
registerCoreMember(EquipCommand.class,
"EQUIP", "equip (<entity>|...) (hand:<item>) (head:<item>) (chest:<item>) (legs:<item>) (boots:<item>) (saddle:<item>) (horse_armor:<item>)", 1);
"EQUIP", "equip (<entity>|...) (offhand:<item>) (hand:<item>) (head:<item>) (chest:<item>) (legs:<item>) (boots:<item>) (saddle:<item>) (horse_armor:<item>)", 1);


// <--[command]
Expand Down
Expand Up @@ -69,6 +69,11 @@ else if (arg.matchesArgumentType(dItem.class)
equipment.put("horse_armor", dItem.valueOf(arg.getValue()));
}

else if (arg.matchesArgumentType(dItem.class)
&& arg.matchesPrefix("offhand")) {
equipment.put("offhand", dItem.valueOf(arg.getValue()));
}

// Default to item in hand if no prefix is used
else if (arg.matchesArgumentType(dItem.class)) {
equipment.put("hand", dItem.valueOf(arg.getValue()));
Expand Down Expand Up @@ -137,6 +142,9 @@ else if (entity.isCitizensNPC()) {
if (equipment.get("boots") != null) {
trait.set(4, equipment.get("boots").getItemStack());
}
if (equipment.get("offhand") != null) {
trait.set(5, equipment.get("offhand").getItemStack());
}
}

}
Expand Down Expand Up @@ -168,7 +176,7 @@ else if (livingEntity.getType() == EntityType.PIG) {
else {

if (equipment.get("hand") != null) {
livingEntity.getEquipment().setItemInHand(equipment.get("hand").getItemStack());
livingEntity.getEquipment().setItemInMainHand(equipment.get("hand").getItemStack());
}
if (equipment.get("head") != null) {
livingEntity.getEquipment().setHelmet(equipment.get("head").getItemStack());
Expand All @@ -182,6 +190,9 @@ else if (livingEntity.getType() == EntityType.PIG) {
if (equipment.get("boots") != null) {
livingEntity.getEquipment().setBoots(equipment.get("boots").getItemStack());
}
if (equipment.get("offhand") != null) {
livingEntity.getEquipment().setItemInOffHand(equipment.get("offhand").getItemStack());
}
}
}
}
Expand Down

0 comments on commit 24cb66a

Please sign in to comment.