本文整理匯總了Java中net.minecraftforge.event.entity.player.ArrowLooseEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrowLooseEvent.setCanceled方法的具體用法?Java ArrowLooseEvent.setCanceled怎麽用?Java ArrowLooseEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.player.ArrowLooseEvent
的用法示例。
在下文中一共展示了ArrowLooseEvent.setCanceled方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fireArrow
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
public void fireArrow(ArrowLooseEvent event)
{
if(MineFantasyBase.isBGLoaded())
{
return;
}
ItemStack bow = event.bow;
float charge = event.charge;
EntityPlayer player = event.entityPlayer;
World world = event.entity.worldObj;
ItemBowMF.loadArrow(player, bow, null, true);
for(ItemStack arrow: ArrowsMF.useableArrows)
{
if(shootSpecificArrow( bow, world, player, charge, arrow))
{
event.setCanceled(true);
return;
}
}
}
示例2: onArrowLooseEvent
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@ForgeSubscribe
public void onArrowLooseEvent(ArrowLooseEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack par1ItemStack = inv.getStackInSlot(inv.currentItem);
if(inv.getCurrentItem().itemID == Item.bow.itemID)
{
if(mod_Rediscovered.QuickBow)
{
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
ItemStack itemstack = player.inventory.armorInventory[2];
if (itemstack != null && itemstack.itemID == mod_Rediscovered.Quiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.LeatherQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.ChainQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.IronQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.GoldQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.DiamondQuiver.itemID)
{
event.setCanceled(true);
}
}
}
}
示例3: handleLoose
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void handleLoose(ArrowLooseEvent event){
if(event.getEntityPlayer() !=null){
ExtendedPlayer exPlayer = ExtendedPlayerProvider.getExtendedPlayer(event.getEntityPlayer());
if(exPlayer !=null){
ExtendedPlayerInventory inv = exPlayer.getInventory();
ItemStack backpack = inv.getStackInSlot(ExtendedPlayerInventory.BACKPACK_SLOT_ID);
if(ItemStackTools.isValid(backpack)){
InventoryBackpackUpgrades upgrades = BackpackUtil.getUpgradeInventory(event.getEntityPlayer(), backpack);
if(upgrades !=null && upgrades.hasUpgrade(BackpackUpgrade.BOW)){
InventoryBackpack backpackInv = BackpackUtil.getInventory(event.getEntityPlayer(), backpack);
if(backpackInv !=null){
for(int i = 0; i < backpackInv.getSize(); i++){
ItemStack st = backpackInv.getStackInSlot(i);
if(ItemStackTools.isValid(st) && st.getItem() instanceof ItemArrow){
if(!EntityUtil.shootArrow(event.getWorld(), event.getEntityPlayer(), event.getBow(), st, event.getCharge())){
backpackInv.decrStackSize(i, 1);
backpackInv.markDirty();
backpackInv.guiSave(event.getEntityPlayer());
inv.setChanged(ExtendedPlayerInventory.BACKPACK_SLOT_ID, true);
event.setCanceled(true);
return;
}
}
}
}
}
}
}
}
}
示例4: onArrowLooseEvent
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onArrowLooseEvent(ArrowLooseEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack par1ItemStack = inv.getStackInSlot(inv.currentItem);
ItemStack blah = new ItemStack(Items.bow);
ItemStack quiver = new ItemStack(mod_Rediscovered.Quiver);
ItemStack lquiver = new ItemStack(mod_Rediscovered.LeatherQuiver);
ItemStack cquiver = new ItemStack(mod_Rediscovered.ChainQuiver);
ItemStack gquiver = new ItemStack(mod_Rediscovered.GoldQuiver);
ItemStack iquiver = new ItemStack(mod_Rediscovered.IronQuiver);
ItemStack dquiver = new ItemStack(mod_Rediscovered.DiamondQuiver);
ItemStack lcquiver = new ItemStack(mod_Rediscovered.LeatherChainQuiver);
if(inv.getCurrentItem().equals(blah))
{
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
ItemStack itemstack = player.inventory.armorInventory[2];
if (itemstack != null && (itemstack.equals(quiver) || itemstack.equals(lquiver) || itemstack.equals(cquiver) || itemstack.equals(iquiver) || itemstack.equals(gquiver) || itemstack.equals(dquiver) || itemstack.equals(lcquiver)))
{
event.setCanceled(true);
}
}
}
示例5: detectArrow
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void detectArrow(ArrowLooseEvent event)
{
if (!ConfigHandler.BACKPACK_ABILITIES) return;
if (Wearing.isWearingTheRightBackpack(event.entityPlayer, "Skeleton"))
{
InventoryBackpack backpack = new InventoryBackpack(Wearing.getWearingBackpack(event.entityPlayer));
if (backpack.hasItem(Items.arrow))
{
ServerActions.leakArrow(event.entityPlayer, event.bow, event.charge);
event.setCanceled(true);
}
}
}
示例6: onArrowLooseEvent
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onArrowLooseEvent(ArrowLooseEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack par1ItemStack = inv.getStackInSlot(inv.currentItem);
ItemStack blah = new ItemStack(Items.bow);
ItemStack quiver = new ItemStack(mod_Rediscovered.Quiver);
ItemStack lquiver = new ItemStack(mod_Rediscovered.LeatherQuiver);
ItemStack cquiver = new ItemStack(mod_Rediscovered.ChainQuiver);
ItemStack gquiver = new ItemStack(mod_Rediscovered.GoldQuiver);
ItemStack iquiver = new ItemStack(mod_Rediscovered.IronQuiver);
ItemStack dquiver = new ItemStack(mod_Rediscovered.DiamondQuiver);
ItemStack squiver = new ItemStack(mod_Rediscovered.LeatherChainQuiver);
if(inv.getCurrentItem().equals(blah))
{
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
ItemStack itemstack = player.inventory.armorInventory[2];
if (itemstack != null && (itemstack.equals(quiver) || itemstack.equals(lquiver) || itemstack.equals(cquiver) || itemstack.equals(iquiver) || itemstack.equals(gquiver) || itemstack.equals(dquiver) || itemstack.equals(squiver)))
{
event.setCanceled(true);
}
}
}
示例7: arrowLoose
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void arrowLoose(ArrowLooseEvent event) {
if (event.bow == null)
return;
IInventory invt = event.entityPlayer.inventory;
for (int i = 0; i < invt.getSizeInventory(); i++) {
ItemStack arrow = invt.getStackInSlot(i);
if (arrow != null && arrow.stackSize > 0 && arrow.getItem() == ModItems.tipped_arrow) {
float charge = event.charge / 20.0F;
charge = (charge * charge + charge * 2.0F) / 3.0F;
if (charge < 0.1D)
return;
if (charge > 1.0F)
charge = 1.0F;
EntityTippedArrow arrowEntity = new EntityTippedArrow(event.entityPlayer.worldObj, event.entityPlayer, charge * 2.0F);
arrowEntity.setEffect(TippedArrow.getEffect(arrow));
if (charge == 1.0F)
arrowEntity.setIsCritical(true);
int power = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, event.bow);
if (power > 0)
arrowEntity.setDamage(arrowEntity.getDamage() + power * 0.5D + 0.5D);
int punch = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, event.bow);
if (punch > 0)
arrowEntity.setKnockbackStrength(punch);
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, event.bow) > 0)
arrowEntity.setFire(100);
event.bow.damageItem(1, event.entityPlayer);
event.entityPlayer.worldObj.playSoundAtEntity(event.entityPlayer, "random.bow", 1.0F, 1.0F / (event.entityPlayer.worldObj.rand.nextFloat() * 0.4F + 1.2F) + charge * 0.5F);
if (!event.entityPlayer.capabilities.isCreativeMode && --arrow.stackSize <= 0)
event.entityPlayer.inventory.setInventorySlotContents(i, null);
if (!event.entityPlayer.worldObj.isRemote)
event.entityPlayer.worldObj.spawnEntityInWorld(arrowEntity);
event.setCanceled(true);
return;
}
}
}
示例8: onArrowLoose
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onArrowLoose(ArrowLooseEvent parEvent)
{
//Compare To: @ItemBow
int j = parEvent.charge;
if (j < 40) return;
World worldIn = parEvent.entityPlayer.worldObj;
ItemStack stack = parEvent.bow;
Random itemRand = new Random();
EntityPlayer playerIn = parEvent.entityPlayer;
boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
if (flag || playerIn.inventory.hasItem(Items.arrow))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityArrow entityarrow = new EntityArrowShatter(worldIn, playerIn, f * 2.0F);
entityarrow.setIsCritical(true);
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (k > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (l > 0)
{
entityarrow.setKnockbackStrength(l);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
{
entityarrow.setFire(100);
}
stack.damageItem(1, playerIn);
worldIn.playSoundAtEntity(playerIn, Sounds.RANDOM_BOW, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag)
{
entityarrow.canBePickedUp = 2;
}
else
{
playerIn.inventory.consumeInventoryItem(Items.arrow);
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(stack.getItem())]);
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(entityarrow);
}
parEvent.setCanceled(true);
}
}
示例9: onBowFiring
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBowFiring(ArrowLooseEvent event) {
//Check if bow is charged enough
float f = new PlayerEventChild.QuiverArrowEvent.ChargeCalculations(event).getCharge();
if(f>=0.1F){
ItemStack stack = QuiverArrowRegistry.getArrowContainer(event.getBow(), event.getEntityPlayer());
if(stack.getItem() instanceof IArrowContainer2){
IArrowContainer2 quiver = (IArrowContainer2) stack.getItem();
World world = event.getEntityPlayer().world;
EntityArrow entityarrow = quiver.getArrowType(stack, world, event.getEntityPlayer(), f*3.0F);
if(entityarrow!=null){
PlayerEventChild.QuiverArrowEvent.Firing arrowEvent = new PlayerEventChild.QuiverArrowEvent.Firing(event, stack, entityarrow);
if(!MinecraftForge.EVENT_BUS.post(arrowEvent)){
quiver.onPreArrowFired(arrowEvent);
entityarrow.setAim(arrowEvent.getArcher(), arrowEvent.getArcher().rotationPitch, arrowEvent.getArcher().rotationYaw, 0, f*3F, 1F);
if (arrowEvent.isCritical || f == 1.0F)
entityarrow.setIsCritical(true);
if(arrowEvent.addEnchantments){
int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, event.getBow());
if (k > 0){
entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, event.getBow());
if (l > 0){
entityarrow.setKnockbackStrength(l);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, event.getBow()) > 0){
entityarrow.setFire(100);
}
}
if(arrowEvent.bowDamage>0) {
event.getBow().damageItem(arrowEvent.bowDamage, event.getEntityPlayer());
event.getEntityPlayer().addStat(StatList.getObjectUseStats(event.getBow().getItem()));
}
if(arrowEvent.bowSoundVolume>0)
world.playSound(null, arrowEvent.getArcher().posX, arrowEvent.getArcher().posY, arrowEvent.getArcher().posZ, arrowEvent.bowSound, SoundCategory.PLAYERS, arrowEvent.bowSoundVolume, 1.0F / (arrowEvent.getPlayer().getRNG().nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (!world.isRemote)
world.spawnEntity(entityarrow);
quiver.onArrowFired(world, arrowEvent.getPlayer(), stack, event.getBow(), entityarrow);
//Canceling the event, since we successfully fired our own arrow
event.setCanceled(true);
}
}
}
}
}