本文整理匯總了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);
}