use updated battlegear2 api (#99)

* use updated battlegear2 api

* Update dependencies.gradle

---------

Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
AlexdoruandMartin Robertz authored and GitHub committed 2023-10-14 20:38:39 +02:00
1 parent b8950a1893
commit d696ad50c3
5 files changed
+16 -13

No files matched your search

@@ -12,7 +12,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.common.Loader;
import mods.battlegear2.api.core.InventoryPlayerBattle;
import mods.battlegear2.api.core.IInventoryPlayerBattle;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.tools.AbilityHelper;
@@ -27,6 +27,8 @@ import tconstruct.weaponry.entity.BoltEntity;
public class Crossbow extends ProjectileWeapon {
private static final boolean isBattlegear2Loaded = Loader.isModLoaded("battlegear2");
public Crossbow() {
super(0, "Crossbow");
this.setMaxDamage(100);
@@ -218,8 +220,8 @@ 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 (isBattlegear2Loaded) {
ItemStack offhand = ((IInventoryPlayerBattle) player.inventory).battlegear2$getCurrentOffhandWeapon();
if (offhand != null && (offhand.getItem() instanceof BoltAmmo)
&& ((IAmmo) offhand.getItem()).getAmmoCount(offhand) > 0) {
return offhand;