當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。