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


Java ActionResult.newResult方法代碼示例

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


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

示例1: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer playerIn, EnumHand handIn) {
    ItemStack iStack = playerIn.getHeldItem(handIn);
    if (iStack.getItemDamage() < iStack.getMaxDamage()) {
        double factor = 0.2D * getPressure(iStack);
        world.playSound(playerIn.posX, playerIn.posY, playerIn.posZ, Sounds.CANNON_SOUND, SoundCategory.PLAYERS, 1.0F, 0.7F + (float) factor * 0.2F, false);
        EntityVortex vortex = new EntityVortex(world, playerIn);
        Vec3d directionVec = playerIn.getLookVec().normalize();
        vortex.posX += directionVec.x;
        vortex.posY += directionVec.y;
        vortex.posZ += directionVec.z;
        vortex.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 0.0F);
        vortex.motionX *= factor;
        vortex.motionY *= factor;
        vortex.motionZ *= factor;
        if (!world.isRemote) world.spawnEntity(vortex);

        iStack.setItemDamage(iStack.getItemDamage() + PneumaticValues.USAGE_VORTEX_CANNON);
        if (iStack.getItemDamage() > iStack.getMaxDamage()) {
            iStack.setItemDamage(iStack.getMaxDamage());
        }
    }

    return ActionResult.newResult(EnumActionResult.SUCCESS, iStack);
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:26,代碼來源:ItemVortexCannon.java

示例2: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	ItemStack stack = player.getHeldItem(hand); //Not entirely convinced it works
	RayTraceResult result = world.isRemote ? RayTraceHelper.tracePlayerHighlight((EntityPlayerSP) player) : RayTraceHelper.tracePlayerHighlight((EntityPlayerMP) player);
	if(result.typeOfHit != RayTraceResult.Type.BLOCK) {
		if(!world.isRemote) {
			Vector3 vec = Vector3.create(player.posX, player.posY + player.getEyeHeight(), player.posZ);
			vec.add(Vector3.create(player.getLookVec()).multiply(2.5D));
			BlockPos pos = new BlockPos(vec.toVec3d());
			IBlockState replaced = world.getBlockState(pos);
			if(world.isAirBlock(pos) || replaced.getBlock().isReplaceable(world, pos)) {
				IBlockState state = ModBlocks.ANGSTROM.getDefaultState();
				SoundType type = ModBlocks.ANGSTROM.getSoundType(state, world, pos, player);
				world.setBlockState(pos, state);
				world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), type.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
			}
			if(!player.capabilities.isCreativeMode) {
				stack.shrink(1);
			}
		}
		return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
	}
	return ActionResult.newResult(EnumActionResult.PASS, stack);
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:25,代碼來源:ItemAngstrom.java

示例3: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
        
	ItemStack toConvert = convertEdibles(stack);
	if (!UniqueCrops.baublesLoaded) {
		if (!world.isRemote)
			player.setHeldItem(hand, toConvert);
		return ActionResult.newResult(EnumActionResult.PASS, toConvert);
	} else {
		ItemStack bauble = BaublesApi.getBaublesHandler(player).getStackInSlot(6);
		if (bauble == null || (bauble != null && bauble.getItem() != UCBaubles.emblemIronstomach)) {
			if (!world.isRemote) {
				player.setHeldItem(hand, toConvert);
			}
			return ActionResult.newResult(EnumActionResult.PASS, toConvert);
		}
	}
	return super.onItemRightClick(stack, world, player, hand);
   }
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:20,代碼來源:ItemEdibleMetal.java

示例4: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
    ItemStack stack = player.getHeldItem(hand);
    
    if (isCooked)
    {
        player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.marshmallowCooked));
        player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.roastingStick));
        stack.setCount(stack.getCount() - 1);
    }
    else
    {
        player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.marshmallow));
        player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.roastingStick));
        stack.setCount(stack.getCount() - 1);
    }

    if (stack.getCount() <= 0)
    {
        player.inventory.setItemStack(ItemStack.EMPTY);
        ForgeEventFactory.onPlayerDestroyItem(player, stack, hand);
    }
    player.inventoryContainer.detectAndSendChanges();
    return ActionResult.newResult(EnumActionResult.PASS, stack);
}
 
開發者ID:einsteinsci,項目名稱:BetterBeginningsReborn,代碼行數:27,代碼來源:ItemRoastingStickMallow.java

示例5: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
    ItemStack stack = player.getHeldItem(hand);
    
    if (player.inventory.hasItemStack(new ItemStack(RegisterItems.marshmallow)))
    {
        stack.setCount(stack.getCount() - 1);
        ItemStack mallowStick = new ItemStack(RegisterItems.roastingStickRawMallow);
        if (!player.inventory.addItemStackToInventory(mallowStick))
        {
            EntityItem drop = new EntityItem(world, player.posX, player.posY, player.posZ, mallowStick);

            world.spawnEntity(drop);
        }

        stack.setCount(stack.getCount() - 1); // Why is this done twice?
        if (stack.getCount() <= 0)
        {
            player.inventory.setItemStack(ItemStack.EMPTY);
            ForgeEventFactory.onPlayerDestroyItem(player, stack, hand);
        }
    }
    player.inventoryContainer.detectAndSendChanges();
    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
 
開發者ID:einsteinsci,項目名稱:BetterBeginningsReborn,代碼行數:27,代碼來源:ItemRoastingStick.java

示例6: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    if (handIn != EnumHand.MAIN_HAND) return ActionResult.newResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
    ItemStack stack = playerIn.getHeldItemMainhand();
    if (worldIn.isRemote) {
        BlockPos pos = getGPSLocation(stack);
        FMLCommonHandler.instance().showGuiScreen(new GuiGPSTool(pos != null ? pos : new BlockPos(0, 0, 0), getVariable(stack)));
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:11,代碼來源:ItemGPSTool.java

示例7: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    if (handIn != EnumHand.MAIN_HAND) return ActionResult.newResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
    if (!worldIn.isRemote) {
        NetworkHandler.sendTo(new PacketSyncAmadronOffers(AmadronOfferManager.getInstance().getAllOffers()), (EntityPlayerMP) playerIn);
        playerIn.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.AMADRON.ordinal(), playerIn.world, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItemMainhand());
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:10,代碼來源:ItemAmadronTablet.java

示例8: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (handIn != EnumHand.MAIN_HAND) return ActionResult.newResult(EnumActionResult.PASS, stack);
    if (!world.isRemote) {
        openGui(player, stack);
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:10,代碼來源:ItemRemote.java

示例9: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (handIn != EnumHand.MAIN_HAND) return ActionResult.newResult(EnumActionResult.PASS, stack);
    if (!world.isRemote) {
        player.openGui(PneumaticCraftRepressurized.instance, ((SemiBlockLogistics) getSemiBlock(world, null, stack)).getGuiID().ordinal(), world, 0, 0, 0);
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:10,代碼來源:ItemLogisticsFrame.java

示例10: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@SuppressWarnings("ConstantConditions")
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	if (!world.isRemote) {
		RayTraceResult result = RayTraceHelper.rayTraceResult(player, RayTraceHelper.fromLookVec(player, 2), true, true);
		if (result != null && result.typeOfHit == ENTITY && result.entityHit instanceof EntityLivingBase) {
			setVictim(player.getHeldItem(hand), (EntityLivingBase) result.entityHit);
		}
	}
	return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:12,代碼來源:ItemTaglock.java

示例11: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
	ItemStack itemstack = playerIn.getHeldItem(hand);
	ItemStack copy = playerIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
	playerIn.playSound(SoundEvents.ENTITY_LINGERINGPOTION_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

	if (!worldIn.isRemote) {
		EntityBrew brew = new EntityBrew(worldIn, playerIn, copy, EntityBrew.BrewDispersion.LINGER);

		brew.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
		worldIn.spawnEntity(brew);
	}

	return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:16,代碼來源:ItemBrewLinger.java

示例12: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
	ItemStack itemstack = playerIn.getHeldItem(hand);
	ItemStack copy = playerIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
	playerIn.playSound(SoundEvents.ENTITY_SPLASH_POTION_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

	if (!worldIn.isRemote) {
		EntityBrew brew = new EntityBrew(worldIn, playerIn, copy, EntityBrew.BrewDispersion.SPLASH);

		brew.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
		worldIn.spawnEntity(brew);
	}

	return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:16,代碼來源:ItemBrewSplash.java

示例13: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
	ItemStack stack = playerIn.getHeldItem(handIn);

	if (playerIn.isSneaking() && stack.hasTagCompound()) {
		stack.getTagCompound().setBoolean("automatic", !stack.getTagCompound().getBoolean("automatic"));
		if (worldIn.isRemote) {
			playerIn.sendMessage(new TextComponentString("Automatic mode has been toggled to " + stack.getTagCompound().getBoolean("automatic") + "."));
		}
		return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
	}

	return ActionResult.newResult(EnumActionResult.FAIL, stack);
}
 
開發者ID:Zundrel,項目名稱:Never-Enough-Currency,代碼行數:15,代碼來源:ItemLinkingCard.java

示例14: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	if (world.isRemote) return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
	
	ItemStack stack = player.getHeldItem(hand);
	
	boolean success = unloadChunk(stack);
	if (success) {
		//TODO: Sound and/or particles to indicate chunk unloading.
		//System.out.println("Chunk Unloaded.");
	}
	
	return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:15,代碼來源:ItemChunkUnloader.java

示例15: onItemRightClick

import net.minecraft.util.ActionResult; //導入方法依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
	playerIn.setActiveHand(hand);
	return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:6,代碼來源:ItemBrewDrink.java


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