本文整理汇总了Java中mods.battlegear2.api.IAllowItem类的典型用法代码示例。如果您正苦于以下问题:Java IAllowItem类的具体用法?Java IAllowItem怎么用?Java IAllowItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAllowItem类属于mods.battlegear2.api包,在下文中一共展示了IAllowItem类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isMainHand
import mods.battlegear2.api.IAllowItem; //导入依赖的package包/类
/**
* Defines a combination of left hand/right hand items that is valid to wield
*
* @param main Item to be wield in the right hand
* @param off Item to be wield in the left hand
* @param wielder The player trying to wield this combination of items
* @return true if the right hand item allows left hand item
*/
public static boolean isMainHand(ItemStack main, ItemStack off, EntityPlayer wielder) {
if(main.isEmpty())
return true;
if(main.getItem() instanceof IWield && !((IWield) main.getItem()).getWieldStyle(main, wielder).isMainhand())
return false;
if(main.getItem() instanceof IAllowItem)//An item using the API
return ((IAllowItem) main.getItem()).allowOffhand(main, off, wielder);//defined by the item
else if(main.getItem() instanceof IShield)//A shield
return false;
else if(main.getItem() instanceof IArrowContainer2)//A quiver
return true;//anything ?
else if(usagePriorAttack(main, wielder, false))//"Usable" item
return off.isEmpty() || !usagePriorAttack(off, wielder, true);//With empty hand or non "usable item"
else if(isWeapon(main))//A generic weapon
return main.getAttributeModifiers(EntityEquipmentSlot.MAINHAND).containsKey(genericAttack) || WeaponRegistry.isMainHand(main);//With either generic attack, or registered
return false;
}
示例2: isOffHand
import mods.battlegear2.api.IAllowItem; //导入依赖的package包/类
/**
* Defines a item which can be wield in the left hand
* @param off The item to be wield in left hand
* @param main Item to be wield in the right hand
* @param wielder The player trying to wield this item
* @return true if the item is allowed in left hand
*/
public static boolean isOffHand(ItemStack off, ItemStack main, EntityPlayer wielder) {
if(off.isEmpty())
return true;
if(off.getItem() instanceof IWield && !((IWield) off.getItem()).getWieldStyle(off, wielder).isOffhand())
return false;
if(off.getItem() instanceof IAllowItem)//An item using the API
return ((IAllowItem) off.getItem()).allowOffhand(off, main, wielder);//defined by the item
else if(off.getItem() instanceof IShield || off.getItem() instanceof IArrowContainer2 || usagePriorAttack(off, wielder, true))//Shield, Quiver, or "usable"
return true;//always
else if(isWeapon(off))//A generic weapon
return off.getAttributeModifiers(EntityEquipmentSlot.OFFHAND).containsKey(genericAttack) || WeaponRegistry.isOffHand(off);//with a generic attack or registered
return false;
}
示例3: isMainHand
import mods.battlegear2.api.IAllowItem; //导入依赖的package包/类
public static boolean isMainHand(ItemStack main, ItemStack off) {
if(main.getItem() instanceof IAllowItem)
return ((IAllowItem) main.getItem()).allowOffhand(main, off);
else
return mainHandDualWeapons[main.itemID] || WeaponRegistry.isMainHand(main);
}