當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrowLooseEvent.getEntityPlayer方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.ArrowLooseEvent.getEntityPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrowLooseEvent.getEntityPlayer方法的具體用法?Java ArrowLooseEvent.getEntityPlayer怎麽用?Java ArrowLooseEvent.getEntityPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.ArrowLooseEvent的用法示例。


在下文中一共展示了ArrowLooseEvent.getEntityPlayer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBowFire

import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
@SubscribeEvent
public void onBowFire(ArrowLooseEvent event)
{
	EntityPlayer player = event.getEntityPlayer();
	ItemStack stack = event.getBow();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (player != null && stack != null && nbt != null && !player.getEntityWorld().isRemote)
	{
		if (BowAttribute.BARRAGE.hasAttribute(nbt))
		{
			for (int i = 0; i < (int) BowAttribute.BARRAGE.getCalculatedValue(nbt, 3, 1.5); i++)
			{
				EntityArrow entityarrow = new EntityTippedArrow(player.getEntityWorld(), player);
				entityarrow.setAim(player, player.rotationPitch, player.rotationYaw, 0, ((ItemBow) event.getBow().getItem()).getArrowVelocity(event.getCharge()) * 3, 20F);
				entityarrow.pickupStatus = PickupStatus.DISALLOWED;
				player.getEntityWorld().spawnEntity(entityarrow);
			}
		}
	}
}
 
開發者ID:TheXFactor117,項目名稱:Levels,代碼行數:23,代碼來源:EventBarrage.java

示例2: 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;
								}
							}
						}
					}
				}
			}
		}
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:32,代碼來源:EventHandler.java

示例3: onArrowLooseEvent

import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
/**
 * Event listener for Action.SHOOT_ARROW
 */
@SubscribeEvent
public void onArrowLooseEvent(ArrowLooseEvent event) throws IOException
{
    EntityPlayer player = event.getEntityPlayer();
    List<Action> events = CommonProxy.manager.getActions(player);

    if (!player.worldObj.isRemote && events != null)
    {
        events.add(new ShootArrowAction(event.getCharge()));
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:15,代碼來源:ActionHandler.java

示例4: onArrowLoose

import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onArrowLoose(ArrowLooseEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    if (this.isActive(player)) {
        if (!event.hasAmmo()) {
            ItemStack stack = event.getBow();
            World world = player.getEntityWorld();
            EntitySkeleton skeleton = (EntitySkeleton) PossessHandler.get(player).getPossessing();
            float velocity = ItemBow.getArrowVelocity(event.getCharge());
            if (velocity >= 0.1) {
                if (!world.isRemote) {
                    EntityTippedArrow arrow = new EntityTippedArrow(world, player);
                    if (skeleton.getSkeletonType() != SkeletonType.STRAY) {
                        arrow.setPotionEffect(new ItemStack(Items.ARROW));
                    } else {
                        arrow.setPotionEffect(new ItemStack(Items.TIPPED_ARROW));
                        arrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
                    }
                    arrow.setAim(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
                    arrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
                    if (velocity == 1.0F) {
                        arrow.setIsCritical(true);
                    }
                    int power = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
                    if (power > 0) {
                        arrow.setDamage(arrow.getDamage() + (double) power * 0.5 + 0.5);
                    }
                    int punch = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
                    if (punch > 0) {
                        arrow.setKnockbackStrength(punch);
                    }
                    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
                        arrow.setFire(100);
                    }
                    stack.damageItem(1, player);
                    world.spawnEntityInWorld(arrow);
                }
                world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (world.rand.nextFloat() * 0.4F + 1.2F) + velocity * 0.5F);
                player.addStat(StatList.getObjectUseStats(stack.getItem()));
            }
        }
    }
}
 
開發者ID:Fararise,項目名稱:Possessed,代碼行數:44,代碼來源:SkeletonHandler.java

示例5: 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);
                }
            }
        }
    }
}
 
開發者ID:Mine-and-blade-admin,項目名稱:Battlegear2,代碼行數:47,代碼來源:BowHookContainerClass2.java


注:本文中的net.minecraftforge.event.entity.player.ArrowLooseEvent.getEntityPlayer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。