mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-25 22:44:23 +00:00
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:
1 parent
3792e46da3
commit
a15044c435
8 files changed
+697
-6
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -11,10 +12,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AmmoItem extends ToolCore implements IAmmo {
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IAmmo {
|
||||
public AmmoItem(int baseDamage, String name) {
|
||||
super(baseDamage);
|
||||
this.setCreativeTab(TConstructRegistry.weaponryTab);
|
||||
@@ -154,4 +162,51 @@ public abstract class AmmoItem extends ToolCore implements IAmmo {
|
||||
// ammo doesn't hurt on smacking stuff with it
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean isOffhandHandDual(ItemStack off) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
event.setCanceled(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
// unused
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
return true;
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -8,12 +9,18 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
/**
|
||||
* Throwing weapons that utilize the ammo system on themselves.
|
||||
* Throwing knifes etc.
|
||||
*/
|
||||
public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup {
|
||||
public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon, IAccuracy, IWindup {
|
||||
public AmmoWeapon(int baseDamage, String name) {
|
||||
super(baseDamage, name);
|
||||
}
|
||||
@@ -134,4 +141,53 @@ public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup
|
||||
public float getZoom(ItemStack itemStack) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
/*---- Battlegear Support START ----*/
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean isOffhandHandDual(ItemStack off) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
onItemRightClick(offhandItem, event.entity.worldObj, event.entityPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
// unused
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
return true;
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import mods.battlegear2.api.core.InventoryPlayerBattle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -57,6 +59,14 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
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 && (checkTinkerArrow(offhand) || checkVanillaArrow(offhand)))
|
||||
{
|
||||
return offhand;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack[] inventory = player.inventory.mainInventory;
|
||||
|
||||
// check hotbar for tinker arrows
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.client.TProxyClient;
|
||||
@@ -23,17 +24,24 @@ import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
/**
|
||||
* Weapons that utilize ammo that uses the ammo system to shoot projectiles.
|
||||
* Bows,...
|
||||
*/
|
||||
public abstract class ProjectileWeapon extends ToolCore implements IAccuracy, IWindup {
|
||||
public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWeapon, IAccuracy, IWindup {
|
||||
public ProjectileWeapon(int baseDamage, String name) {
|
||||
super(baseDamage);
|
||||
|
||||
@@ -474,4 +482,54 @@ public abstract class ProjectileWeapon extends ToolCore implements IAccuracy, IW
|
||||
list.add(currentAmmo.getDisplayName());
|
||||
list.add(StatCollector.translateToLocal("attribute.name.ammo.maxAttackDamage") + ": " + TProxyClient.df.format(damage));
|
||||
}
|
||||
|
||||
/*---- Battlegear Support START ----*/
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean isOffhandHandDual(ItemStack off) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
// unused
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
return true;
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
|
||||
/*---- Battlegear Support END ----*/
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user