当前位置: 首页>>代码示例>>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;未经允许,请勿转载。