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


Java ActionResult类代码示例

本文整理汇总了Java中net.minecraft.util.ActionResult的典型用法代码示例。如果您正苦于以下问题:Java ActionResult类的具体用法?Java ActionResult怎么用?Java ActionResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
        entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitysnowball);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:ItemSnowball.java

示例2: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
	ItemStack is = player.getHeldItem(handIn);
	if (player.getHeldItemMainhand().getCount() > 1) {
		if (worldIn.isRemote) {
			GuiKnapping.staticMaterial = CraftMat.STONE;
			GuiKnapping.staticMaterialSub = this.getSubName(is.getItemDamage());

		} else {
			PlayerData pd = PlayerData.getPlayerData(player.getUniqueID());
			pd.resetKnapCraft();
			pd.setItemStack(player.getHeldItemMainhand());
			pd.setCraftingMaterial(CraftMat.STONE);
		}
	}
	player.openGui(FirmaMod.instance, GuiHandler.GUI_KNAPPING, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
	return new ActionResult<ItemStack>(EnumActionResult.PASS, is);
}
 
开发者ID:trigg,项目名称:Firma,代码行数:19,代码来源:PebbleItem.java

示例3: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);
    ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!itemStackIn.isRemote)
    {
        EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
        entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entitypotion);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:ItemSplashPotion.java

示例4: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	if (!world.isRemote) {
		IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
		for (int i = 0; i < baubles.getSlots(); i++)
			if (baubles.getStackInSlot(i).isEmpty() && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) {
				baubles.setStackInSlot(i, player.getHeldItem(hand).copy());
				if (!player.capabilities.isCreativeMode) {
					player.setHeldItem(hand, ItemStack.EMPTY);
				}
				onEquipped(player.getHeldItem(hand), player);
				break;
			}
	}
	return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:17,代码来源:ItemTalisman.java

示例5: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn);
        entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitypotion);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:ItemLingeringPotion.java

示例6: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
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,代码行数:17,代码来源:ItemElytra.java

示例7: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
@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,代码行数:17,代码来源:SimplyTea.java

示例8: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    playerIn.getCooldownTracker().setCooldown(this, 20);

    if (!worldIn.isRemote)
    {
        EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);
        entityenderpearl.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entityenderpearl);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:ItemEnderPearl.java

示例9: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {

    if(worldIn.isRemote)
    {
        //check to make sure the player didn't just click on a chalk tile
        //it's a little hacky but it gets the job done eh?
        if (worldIn.getBlockState(playerIn.rayTrace(5.0f, 0).getBlockPos()).getBlock()!= ModBlocks.chalkBase) {

            //if the scrap has nbtdata for text, open it.  Otherwise open a blank scrap
            if (itemStackIn.getTagCompound() == null || !itemStackIn.getTagCompound().hasKey("text"))
                Minecraft.getMinecraft().displayGuiScreen(new GuiPaperScrap(""));
            else
                Minecraft.getMinecraft().displayGuiScreen(new GuiPaperScrap(itemStackIn.getTagCompound().getString("text")));
        }
    }


    return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
 
开发者ID:Drazuam,项目名称:RunicArcana,代码行数:21,代码来源:ItemPaperScrap.java

示例10: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
/**
 * Called when the equipped item is right clicked.
 */
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
    ItemStack itemstack = playerIn.getHeldItem(handIn);
		itemstack.shrink(1);

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
    		EntityEgg entityegg = new CoreEntityEgg(worldIn, playerIn);
        entityegg.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntity(entityegg);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
开发者ID:hlgr360,项目名称:SentinentAImod,代码行数:22,代码来源:CoreItemEgg.java

示例11: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (player.isSneaking()) {
        return super.onItemRightClick(world, player, hand);
    }

    if (getItemFreq(itemStack) == 0)
        return new ActionResult<>(EnumActionResult.PASS, itemStack);

    if (!player.capabilities.isCreativeMode) {
        itemStack.shrink(1);
    }
    if (!world.isRemote) {
        world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
        EntityWirelessTracker tracker = new EntityWirelessTracker(world, getItemFreq(itemStack), player);
        world.spawnEntity(tracker);
        WRServerPH.sendThrowTracker(tracker, player);
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:22,代码来源:ItemWirelessTracker.java

示例12: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.getRidingEntity();

        if (itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7 && entitypig.boost())
        {
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.FISHING_ROD);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }

            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:ItemCarrotOnAStick.java

示例13: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
	if (world.isRemote) { return new ActionResult(EnumActionResult.PASS, stack); }	// Not doing this on client side

	if (!player.capabilities.isCreativeMode) { return new ActionResult(EnumActionResult.PASS, stack); }	// Creative mode only

	if (player.isSneaking())
	{
		this.toggleChunkProtection(player);
	}
	else
	{
		this.getFactionInfo(player);
	}

	return new ActionResult(EnumActionResult.PASS, stack);
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:19,代码来源:FactionOverviewCard.java

示例14: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World par2World, EntityPlayer player,
		EnumHand hand) {
	// System.out.println("lel "+stack.getTagCompound().getInteger("wait")+"
	// "+this.allowShot(player,stack, par2World));
	ItemStack stack=player.getHeldItem(hand);
	if (!(stack.hasTagCompound() && stack.getTagCompound().getInteger("wait") > 0)
			&& this.allowShot(player, stack, par2World)) {
		if (!this.usesBowAnimation(stack))
			this.use(stack, par2World, player, 1.8f,
					player.inventory.getStackInSlot(this.getSlotForUse(player, stack)), false);
		else
			// System.out.println("trying");
			player.setActiveHand(hand);
		return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
	}
	return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:19,代码来源:TNTCannon.java

示例15: onItemRightClick

import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = ItemMap.func_190906_a(itemStackIn, worldIn.posX, worldIn.posZ, (byte)0, true, false);
    ItemStack itemstack1 = worldIn.getHeldItem(playerIn);
    itemstack1.func_190918_g(1);

    if (itemstack1.func_190926_b())
    {
        return new ActionResult(EnumActionResult.SUCCESS, itemstack);
    }
    else
    {
        if (!worldIn.inventory.addItemStackToInventory(itemstack.copy()))
        {
            worldIn.dropItem(itemstack, false);
        }

        worldIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.SUCCESS, itemstack1);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:ItemEmptyMap.java


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