Tinkers bows in Battlegear slots #2491

Added ability to equip Tinker's bows/crossbow/throwables to Battlegear slots.  Bows will only look in the same offhand, or the main inventory for ammo.
https://github.com/GTNewHorizons/NewHorizons/issues/2491
This commit is contained in:
Kortako committed 2018-02-21 05:51:18 -08:00
1 parent 3792e46da3
commit a15044c435
8 files changed
+697 -6

No files matched your search

@@ -23,6 +23,8 @@ import net.minecraft.world.World;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.tools.TinkerTools;
import cpw.mods.fml.common.Loader;
import mods.battlegear2.api.core.InventoryPlayerBattle;
import java.util.List;
@@ -166,8 +168,14 @@ public class Crossbow extends ProjectileWeapon {
// remove loaded item
if(ammo.getItem() instanceof IAmmo)
((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
else
player.inventory.consumeInventoryItem(ammo.getItem());
else {
if(Loader.isModLoaded("battlegear2")) {
((InventoryPlayerBattle)player.inventory).consumeInventoryItem(ammo.getItem());
}
else {
player.inventory.consumeInventoryItem(ammo.getItem());
}
}
playReloadSound(world, player, weapon, ammo);
@@ -248,6 +256,14 @@ public class Crossbow extends ProjectileWeapon {
@Override
public ItemStack searchForAmmo(EntityPlayer player, ItemStack weapon) {
// arrow priority: hotbar > inventory, tinker arrows > regular arrows
if(Loader.isModLoaded("battlegear2")){
ItemStack offhand = ((InventoryPlayerBattle) player.inventory).getCurrentOffhandWeapon();
if(offhand != null && (offhand.getItem() instanceof BoltAmmo) && ((IAmmo) offhand.getItem()).getAmmoCount(offhand) > 0)
{
return offhand;
}
}
ItemStack[] inventory = player.inventory.mainInventory;
// check hotbar for tinker arrows