当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.swingArm方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.swingArm方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.swingArm方法的具体用法?Java EntityPlayer.swingArm怎么用?Java EntityPlayer.swingArm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.swingArm方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: itemInteractionForEntity

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand) {
    if (target.getEntityWorld().isRemote) return false;
    if (target instanceof EntityPlayer || !target.isNonBoss()) return false;
    if (containsEntity(stack)) return false;
    String entityID = EntityList.getKey(target).toString();
    if (isBlacklisted(entityID)) return false;
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setString("entity", entityID);
    nbt.setInteger("id", EntityList.getID(target.getClass()));
    target.writeToNBT(nbt);
    stack.setTagCompound(nbt);
    playerIn.swingArm(hand);
    playerIn.setHeldItem(hand, stack);
    target.setDead();
    return true;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:18,代码来源:MobImprisonmentToolItem.java

示例2: onBlockActivated

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (Config.getInstance().boringSamples)
    {
        String resource = Types.Modded.byMetadata(state.getBlock().getMetaFromState(state)).getResource();
        playerIn.sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
    }
    else
    {
        this.dropBlockAsItem(worldIn, pos, state, 0);
    }
    worldIn.setBlockToAir(pos);
    playerIn.swingArm(EnumHand.MAIN_HAND);
    return true;
}
 
开发者ID:oitsjustjose,项目名称:Geolosys,代码行数:17,代码来源:BlockSample.java

示例3: onBlockActivated

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (Config.getInstance().boringSamples)
    {
        String resource = Types.Vanilla.byMetadata(state.getBlock().getMetaFromState(state)).getResource();
        playerIn.sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
    }
    else
    {
        this.dropBlockAsItem(worldIn, pos, state, 0);
    }
    worldIn.setBlockToAir(pos);
    playerIn.swingArm(EnumHand.MAIN_HAND);
    return true;
}
 
开发者ID:oitsjustjose,项目名称:Geolosys,代码行数:17,代码来源:BlockSampleVanilla.java

示例4: processInteract

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
protected boolean processInteract(EntityPlayer player, EnumHand hand)
{
	ItemStack stack = player.getHeldItem(hand);
	if (!stack.isEmpty() && stack.getItem() == Items.FLINT_AND_STEEL)
	{
		this.world.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
		player.swingArm(hand);

		if (!this.world.isRemote)
		{
			this.ignite();
			stack.damageItem(1, player);
			return true;
		}
	}
	return super.processInteract(player, hand);
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:19,代码来源:EntityCreeperween.java

示例5: processInteract

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
protected boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.FLINT_AND_STEEL)
    {
        this.world.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
        player.swingArm(hand);

        if (!this.world.isRemote)
        {
            this.ignite();
            itemstack.damageItem(1, player);
            return true;
        }
    }

    return super.processInteract(player, hand);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:EntityCreeper.java

示例6: processInteract

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
protected boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    if (stack != null && stack.getItem() == Items.FLINT_AND_STEEL)
    {
        this.worldObj.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
        player.swingArm(hand);

        if (!this.worldObj.isRemote)
        {
            this.ignite();
            stack.damageItem(1, player);
            return true;
        }
    }

    return super.processInteract(player, hand, stack);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:EntityCreeper.java

示例7: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingArm(hand);
    }
    else
    {
        worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
        }

        playerIn.swingArm(hand);
        playerIn.addStat(StatList.getObjectUseStats(this));
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:ItemFishingRod.java

示例8: sausageInteract

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public static void sausageInteract(PlayerInteractEvent.EntityInteract e) {
    EntityPlayer player = e.getEntityPlayer();
    if (!player.world.isRemote) {
        if (e.getTarget() instanceof OinkSausage) {
            if (player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).isEmpty() && player.isSneaking() && e.getHand() == EnumHand.MAIN_HAND && sausageGlow) {
                sausageGlow = false;
            } else if (player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).isEmpty() && player.isSneaking() && e.getHand() == EnumHand.MAIN_HAND && !sausageGlow) {
                sausageGlow = true;
            }
        }
    } else {
        player.swingArm(EnumHand.MAIN_HAND);
    }
}
 
开发者ID:OCDiary,项目名称:TheOink,代码行数:16,代码来源:OinkEntityEvents.java

示例9: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (worldIn.fishEntity != null)
    {
        int i = worldIn.fishEntity.handleHookRetraction();
        itemstack.damageItem(i, worldIn);
        worldIn.swingArm(playerIn);
    }
    else
    {
        itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!itemStackIn.isRemote)
        {
            EntityFishHook entityfishhook = new EntityFishHook(itemStackIn, worldIn);
            int j = EnchantmentHelper.func_191528_c(itemstack);

            if (j > 0)
            {
                entityfishhook.func_191516_a(j);
            }

            int k = EnchantmentHelper.func_191529_b(itemstack);

            if (k > 0)
            {
                entityfishhook.func_191517_b(k);
            }

            itemStackIn.spawnEntityInWorld(entityfishhook);
        }

        worldIn.swingArm(playerIn);
        worldIn.addStat(StatList.getObjectUseStats(this));
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:41,代码来源:ItemFishingRod.java

示例10: processInitialInteract

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand)
{
    if(!world.isRemote && !activating)
    {
        ItemStack is = player.getHeldItem(hand);
        if(is.getItem() == Item.getItemFromBlock(Blocks.TORCH) && getTorches() < 512)
        {
            addTorches(1);
            if(!player.capabilities.isCreativeMode)
            {
                is.shrink(1);
                if(is.isEmpty())
                {
                    player.inventory.mainInventory.set(player.inventory.currentItem, ItemStack.EMPTY);
                }
            }
            player.swingArm(hand);
            return true;
        }
        else if(is.getItem() == Items.GUNPOWDER && getGP() < 512)
        {
            addGP(1);
            if(!player.capabilities.isCreativeMode)
            {
                is.shrink(1);
                if(is.isEmpty())
                {
                    player.inventory.mainInventory.set(player.inventory.currentItem, ItemStack.EMPTY);
                }
            }
            player.swingArm(hand);
            return true;
        }
        else if(is.getItem() == Items.FLINT_AND_STEEL)
        {
            activating = true;
            if(!player.capabilities.isCreativeMode)
            {
                is.setItemDamage(is.getItemDamage() + 1);
            }
            initiator = player;
            player.swingArm(hand);
            return true;
        }
        else if(is.getItem() == Items.GOLD_NUGGET && getSplits() < 16)
        {
            addSplit();
            if(!player.capabilities.isCreativeMode)
            {
                is.shrink(1);
                if(is.isEmpty())
                {
                    player.inventory.mainInventory.set(player.inventory.currentItem, ItemStack.EMPTY);
                }
            }
            player.swingArm(hand);
            return true;
        }
    }
    if(world.isRemote && (player.getHeldItem(hand).getItem() == Item.getItemFromBlock(Blocks.TORCH) || player.getHeldItem(hand).getItem() == Items.GUNPOWDER || player.getHeldItem(hand).getItem() == Items.FLINT_AND_STEEL || player.getHeldItem(hand).getItem() == Items.GOLD_NUGGET))
    {
        player.swingArm(hand);
        return true;
    }
    return false;
}
 
开发者ID:iChun,项目名称:Torched,代码行数:68,代码来源:EntityTorchFirework.java

示例11: onLocalPlayerUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) {
    EntityPlayer localPlayer = MC.player;
    Entity target = LocalPlayerUtils.getTargetEntity();
    // local player eye pos
    Vec3d selfPos = EntityUtils.getEyePos(localPlayer);
    // local player look vec
    Vec3d selfLookVec = localPlayer.getLookVec();
    // local player view angles
    Angle viewAngles = VectorUtils.vectorAngle(selfLookVec);
    if(hold_target.get()) {
        if(target == null ||
                !isValidTarget(target, EntityUtils.getOBBCenter(target), selfPos, selfLookVec, viewAngles)) {
            target = findTargetEntity(selfPos, selfLookVec, viewAngles);
        }
    } else {
        target = findTargetEntity(selfPos, selfLookVec, viewAngles);
    }
    if(target != null) {
        if(!isHoldingProjectileItem()) {
            Angle aim = Utils.getLookAtAngles(target);
            if (!silent.get())
                LocalPlayerUtils.setViewAngles(aim);
            if (canAttack(localPlayer, target)) {
                // attack entity
                MC.playerController.attackEntity(MC.player, target);
                // swing hand
                localPlayer.swingArm(EnumHand.MAIN_HAND);
                // for rotation packets
                if (silent.get()) {
                    LocalPlayerUtils.setActiveFakeAngles(true);
                    LocalPlayerUtils.setFakeViewAngles(aim);
                    LocalPlayerUtils.sendRotatePacket(aim);
                    return;
                }
            }
        } else {
            ItemStack heldItem = localPlayer.getHeldItemMainhand();
            //Vec3d startPos = EntityUtils.getInterpolatedPos(target, 1).addVector(0, target.getEyeHeight(), 0);
            //Vec3d endPos = EntityUtils.getInterpolatedPos(target, 5).addVector(0, target.getEyeHeight() / 2, 0);
            // this will find the angle we need to shoot at
            ProjectileUtils.ProjectileTraceResult result = new ProjectileUtils.ProjectileTraceResult();
            boolean exists = ProjectileUtils.projectileTrajectoryHitsEntity(target, selfPos, getAimPos(target), result);
            if(!exists || result.shootAngle == null) {
                LocalPlayerUtils.setProjectileTargetAcquired(false);
            } else {
                // we have a projectile target
                LocalPlayerUtils.setProjectileTargetAcquired(true);
                // set view angles
                LocalPlayerUtils.setFakeViewAngles(result.shootAngle);
                if (!silent.get() && Bindings.use.getBinding().isKeyDown()) {
                    LocalPlayerUtils.setViewAngles(result.shootAngle);
                }
                // fake angles no active (wont change rotation packets)
                LocalPlayerUtils.setActiveFakeAngles(false);
                // bow auto attack will release the use key when
                // the force is greater than or equal to the max force
                if(projectile_auto_attack.get() &&
                        Bindings.use.getBinding().isKeyDown() &&
                        ProjectileUtils.getForce(heldItem) >= result.maxForce) {
                    Bindings.use.setPressed(false);
                }
                return;
            }
        }
    }
    // disable aiming from last tick
    LocalPlayerUtils.setActiveFakeAngles(false);
    LocalPlayerUtils.setProjectileTargetAcquired(false);
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:71,代码来源:AimbotMod.java

示例12: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
	ItemStack stack = player.getHeldItem(hand);
	if (stack.getItem().equals(ModRegistry.WRITTEN_PARCHMENT))
	{
		Pair<NotebookCategory, Boolean> catInfo = getToUnlock(stack);
		if (catInfo != null)
		{
			if (!world.isRemote)
			{
				INotebookInfo cap = player.getCapability(INotebookInfo.CAP, null);
				if (cap != null)
				{
					NotebookCategory cat = catInfo.first();
					if (cat != null)
					{
						if (!cat.equals(NotebookCategories.UNKNOWN_REALMS)
								&& cap.isUnlocked(cat.getPrerequisiteTag())
								&& !cap.isUnlocked(cat.getRequiredTag()))
						{
							cap.setUnlocked(cat.getRequiredTag());
						}
						if (catInfo.second())
						{
							for (NotebookCategory mightBeParent : NotebookCategory.REGISTRY.getValues())
							{
								if (mightBeParent != null && mightBeParent.getRequiredTag() != null)
								{
									if (mightBeParent.getRequiredTag().equals(cat.getPrerequisiteTag()))
									{
										ArcaneMagicPacketHandler.INSTANCE
												.sendTo(new PacketNotebookToastExpanded(mightBeParent,
														cat.getRequiredTag(), true), (EntityPlayerMP) player);
									}
								}
							}
						} else
						{
							ArcaneMagicPacketHandler.INSTANCE.sendTo(new PacketNotebookToastOrFail(cat, true),
									(EntityPlayerMP) player);
						}

					} else
					{
						ArcaneMagicPacketHandler.INSTANCE.sendTo(new PacketNotebookToastOrFail(cat, true),
								(EntityPlayerMP) player);
					}
				}
			}
		}

		world.playSound(player, player.getPosition(), ArcaneMagicSoundHandler.randomWriteSound(),
				SoundCategory.PLAYERS, 1, 1);
		player.setHeldItem(hand, ItemStack.EMPTY);
		player.swingArm(hand);
		if (!world.isRemote)
		{
			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
		}
	}
	return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:63,代码来源:ItemParchment.java


注:本文中的net.minecraft.entity.player.EntityPlayer.swingArm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。