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


Java EnumActionResult.FAIL属性代码示例

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


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

示例1: onItemRightClick

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
	Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
	PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
	
	if (statsCap != null && playerInfo != null)
	{
		if (statsCap.getMana() - this.manaPerUse >= 0 && playerInfo.getPlayerLevel() >= NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
		{	
			player.setActiveHand(hand);
			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.inventory.getCurrentItem());
		}
	}
	
	if (playerInfo.getPlayerLevel() < NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
	{
		player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will take significantly more damage if it is not removed."));
	}
	
	return new ActionResult<ItemStack>(EnumActionResult.FAIL, player.inventory.getCurrentItem());
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:22,代码来源:ItemLEMagical.java

示例2: onItemRightClick

@Override
   public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn){
       ItemStack stack = playerIn.getHeldItem(handIn);
       if (stack.getMetadata() == 0){
       	RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
       	if (raytraceresult != null && raytraceresult.typeOfHit != null && raytraceresult.typeOfHit == Type.BLOCK){
       		IBlockState state = worldIn.getBlockState(raytraceresult.getBlockPos());
       		if (state.getBlock() == Blocks.WATER){
       			stack.setItemDamage(1);
       			playerIn.setHeldItem(handIn, stack);
       			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS,stack);
       		}
       	}
       }
	return new ActionResult<ItemStack>(EnumActionResult.FAIL,stack);
}
 
开发者ID:elucent,项目名称:SimplyTea,代码行数:16,代码来源:SimplyTea.java

示例3: onItemRightClick

public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemStackIn);
    ItemStack itemstack = playerIn.getItemStackFromSlot(entityequipmentslot);

    if (itemstack == null)
    {
        playerIn.setItemStackToSlot(entityequipmentslot, itemStackIn.copy());
        itemStackIn.stackSize = 0;
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
    else
    {
        return new ActionResult(EnumActionResult.FAIL, itemStackIn);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:16,代码来源:ItemArmor.java

示例4: onItemUse

@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);

    if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && (state.getBlock()== net.minecraft.init.Blocks.GRASS ||state.getBlock()==net.minecraft.init.Blocks.DIRT|| state.getBlock()==net.minecraft.init.Blocks.SAND) && worldIn.isAirBlock(pos.up()))
    {
    	worldIn.setBlockState(pos.up(), Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, "palm_sapling")).getDefaultState());
        --stack.stackSize;
        return EnumActionResult.SUCCESS;
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:16,代码来源:ItemDates.java

示例5: onItemUse

/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
    BlockPos blockpos = flag ? pos : pos.offset(facing);

    if (playerIn.canPlayerEdit(blockpos, facing, stack) && worldIn.canBlockBePlaced(worldIn.getBlockState(blockpos).getBlock(), blockpos, false, facing, (Entity)null, stack) && Blocks.REDSTONE_WIRE.canPlaceBlockAt(worldIn, blockpos))
    {
        --stack.stackSize;
        worldIn.setBlockState(blockpos, Blocks.REDSTONE_WIRE.getDefaultState());
        return EnumActionResult.SUCCESS;
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:ItemRedstone.java

示例6: onItemUse

/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    ItemStack itemstack = stack.getHeldItem(pos);

    if (hand == EnumFacing.UP && stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack) && playerIn.getBlockState(worldIn).getBlock() == this.soilBlockID && playerIn.isAirBlock(worldIn.up()))
    {
        playerIn.setBlockState(worldIn.up(), this.crops.getDefaultState());
        itemstack.func_190918_g(1);
        return EnumActionResult.SUCCESS;
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:ItemSeeds.java

示例7: onItemUse

/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    worldIn = worldIn.offset(hand);
    ItemStack itemstack = stack.getHeldItem(pos);

    if (!stack.canPlayerEdit(worldIn, hand, itemstack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        if (playerIn.getBlockState(worldIn).getMaterial() == Material.AIR)
        {
            playerIn.playSound(stack, worldIn, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
            playerIn.setBlockState(worldIn, Blocks.FIRE.getDefaultState(), 11);
        }

        itemstack.damageItem(1, stack);
        return EnumActionResult.SUCCESS;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:ItemFlintAndSteel.java

示例8: onItemUse

/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    pos = pos.offset(facing);

    if (!playerIn.canPlayerEdit(pos, facing, stack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        if (worldIn.isAirBlock(pos))
        {
            worldIn.playSound(playerIn, pos, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
            worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState(), 11);
        }

        stack.damageItem(1, playerIn);
        return EnumActionResult.SUCCESS;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:ItemFlintAndSteel.java

示例9: onItemRightClick

/**
 * Called when the equipped item is right clicked.
 */
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    boolean flag = !this.findAmmo(playerIn).isEmpty();

    ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, worldIn, playerIn, handIn, flag);
    if (ret != null) return ret;

    if (!playerIn.capabilities.isCreativeMode && !flag)
    {
        return flag ? new ActionResult(EnumActionResult.PASS, itemstack) : new ActionResult(EnumActionResult.FAIL, itemstack);
    }
    else
    {
        playerIn.setActiveHand(handIn);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
    }
}
 
开发者ID:TwilightWingsStudio,项目名称:CompositeGear,代码行数:21,代码来源:ItemCGBow.java

示例10: onItemUse

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
   {
	if (!player.getEntityWorld().isRemote)
	{
        return EnumActionResult.SUCCESS;
	}
	
	return EnumActionResult.FAIL;
   }
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:10,代码来源:ItemTest.java

示例11: onItemUse

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (player.getEntityWorld().isRemote) return EnumActionResult.FAIL;
    if (!containsEntity(stack)) return EnumActionResult.FAIL;
    Entity entity = getEntityFromStack(stack, worldIn, true);
    BlockPos blockPos = pos.offset(facing);
    entity.setPositionAndRotation(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5, 0, 0);
    stack.setTagCompound(new NBTTagCompound());
    player.setHeldItem(hand, stack);
    worldIn.spawnEntity(entity);
    if (entity instanceof EntityLiving) ((EntityLiving) entity).playLivingSound();
    return EnumActionResult.SUCCESS;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:14,代码来源:MobImprisonmentToolItem.java

示例12: onItemUse

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
	if (worldIn.isRemote)
	{
		return EnumActionResult.FAIL;
	}

	TileEntity tile = worldIn.getTileEntity(pos);
	if (tile != null && tile.hasCapability(ExPFarmlandCapability.farmlandCap, EnumFacing.UP))
	{
		if (worldIn.isAirBlock(pos.up()))
		{
			// FIXME fix packet pipeline render issues!
			try
			{
				ItemStack held = player.getHeldItem(hand);
				CapabilityExPSeeds seedsCap = (CapabilityExPSeeds) held.getCapability(ExPSeedsCapability.seedsCap, null);
				CropStats stats = new CropStats(seedsCap.getOrCreateStats());
				worldIn.setBlockState(pos.up(), ExPBlocks.crop.getDefaultState());
				TileCrop cropTile = (TileCrop) worldIn.getTileEntity(pos.up());
				ExPCrop cropCap = (ExPCrop) IExPCrop.of(cropTile);
				cropCap.stats = stats;
				cropCap.timeKeeper = new Calendar(IExPWorld.of(worldIn).today().getTime());
				NBTTagCompound sent = new NBTTagCompound();
				sent.setTag("tileData", cropTile.serializeNBT());
				sent.setTag("blockPosData", new DimBlockPos(pos.up(), worldIn.provider.getDimension()).serializeNBT());
				VoidNetwork.sendDataToAllAround(PacketType.TileData, sent, new TargetPoint(worldIn.provider.getDimension(), pos.getX(), pos.up().getY(), pos.getZ(), 96));
				held.shrink(1);
				return EnumActionResult.SUCCESS;
			}
			catch (Exception ex)
			{
				ExPMisc.modLogger.log(LogLevel.Error, "Unable to place seeds at %s!", ex, pos.toString());
			}
		}
	}
	
	return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:40,代码来源:ItemSeeds.java

示例13: onItemRightClick

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
  {
if(!hasDrinkEffect(playerIn, handIn))
	return new ActionResult<ItemStack>(EnumActionResult.FAIL, playerIn.getHeldItem(handIn));
playerIn.setActiveHand(handIn);
      return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
  }
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:8,代码来源:GlassContainer.java

示例14: onItemUse

/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return EnumActionResult.SUCCESS;
    }
    else
    {
        pos = pos.offset(facing);

        if (!playerIn.canPlayerEdit(pos, facing, stack))
        {
            return EnumActionResult.FAIL;
        }
        else
        {
            if (worldIn.getBlockState(pos).getMaterial() == Material.AIR)
            {
                worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2F + 1.0F);
                worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState());
            }

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }

            return EnumActionResult.SUCCESS;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:34,代码来源:ItemFireball.java

示例15: onItemUse

/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    if (playerIn.isRemote)
    {
        return EnumActionResult.SUCCESS;
    }
    else if (hand != EnumFacing.UP)
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        IBlockState iblockstate = playerIn.getBlockState(worldIn);
        Block block = iblockstate.getBlock();
        boolean flag = block.isReplaceable(playerIn, worldIn);

        if (!flag)
        {
            worldIn = worldIn.up();
        }

        int i = MathHelper.floor((double)(stack.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        EnumFacing enumfacing = EnumFacing.getHorizontal(i);
        BlockPos blockpos = worldIn.offset(enumfacing);
        ItemStack itemstack = stack.getHeldItem(pos);

        if (stack.canPlayerEdit(worldIn, hand, itemstack) && stack.canPlayerEdit(blockpos, hand, itemstack))
        {
            IBlockState iblockstate1 = playerIn.getBlockState(blockpos);
            boolean flag1 = iblockstate1.getBlock().isReplaceable(playerIn, blockpos);
            boolean flag2 = flag || playerIn.isAirBlock(worldIn);
            boolean flag3 = flag1 || playerIn.isAirBlock(blockpos);

            if (flag2 && flag3 && playerIn.getBlockState(worldIn.down()).isFullyOpaque() && playerIn.getBlockState(blockpos.down()).isFullyOpaque())
            {
                IBlockState iblockstate2 = Blocks.BED.getDefaultState().withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.FACING, enumfacing).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);
                playerIn.setBlockState(worldIn, iblockstate2, 10);
                playerIn.setBlockState(blockpos, iblockstate2.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD), 10);
                playerIn.notifyNeighborsRespectDebug(worldIn, block, false);
                playerIn.notifyNeighborsRespectDebug(blockpos, iblockstate1.getBlock(), false);
                SoundType soundtype = iblockstate2.getBlock().getSoundType();
                playerIn.playSound((EntityPlayer)null, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                itemstack.func_190918_g(1);
                return EnumActionResult.SUCCESS;
            }
            else
            {
                return EnumActionResult.FAIL;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:59,代码来源:ItemBed.java


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