Search in sources :

Example 51 with ActionResult

use of net.minecraft.util.ActionResult in project takumicraft by TNTModders.

the class ItemTakumiBoltStone method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    Vec3d vec3d = playerIn.getLookVec();
    vec3d = vec3d.normalize().scale(5);
    EntityLightningBolt bolt = new EntityLightningBolt(worldIn, playerIn.posX + vec3d.x, playerIn.posY + vec3d.y, playerIn.posZ + vec3d.z, false);
    worldIn.addWeatherEffect(bolt);
    worldIn.spawnEntity(bolt);
    if (!playerIn.isCreative()) {
        playerIn.getHeldItem(handIn).shrink(1);
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) Vec3d(net.minecraft.util.math.Vec3d)

Example 52 with ActionResult

use of net.minecraft.util.ActionResult in project takumicraft by TNTModders.

the class ItemTakumiChocolateBall method onItemRightClick.

/**
 * Called when the equipped item is right clicked.
 */
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    if (!playerIn.capabilities.isCreativeMode) {
        itemstack.shrink(1);
    }
    worldIn.playSound(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) {
        EntityTakumiChocolateBall entitysnowball = new EntityTakumiChocolateBall(worldIn, playerIn);
        entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntity(entitysnowball);
    }
    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
}
Also used : EnumActionResult(net.minecraft.util.EnumActionResult) ActionResult(net.minecraft.util.ActionResult) EntityTakumiChocolateBall(com.tntmodders.takumi.entity.item.EntityTakumiChocolateBall) ItemStack(net.minecraft.item.ItemStack)

Example 53 with ActionResult

use of net.minecraft.util.ActionResult in project Random-Things by lumien231.

the class ItemDungeonChestGenerator method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
    ItemStack par1ItemStack = par3EntityPlayer.getHeldItem(hand);
    if (!par2World.isRemote && par3EntityPlayer.isSneaking()) {
        NBTTagCompound nbt = par1ItemStack.getTagCompound();
        if (nbt == null) {
            par1ItemStack.setTagCompound(new NBTTagCompound());
            par1ItemStack.getTagCompound().setInteger("tableIndex", 0);
        } else {
            int currentCategory = par1ItemStack.getTagCompound().getInteger("tableIndex");
            if (currentCategory + 1 < LootTableList.getAll().size()) {
                currentCategory++;
            } else {
                currentCategory = 0;
            }
            par1ItemStack.getTagCompound().setInteger("tableIndex", currentCategory);
        }
        return new ActionResult<>(EnumActionResult.SUCCESS, par1ItemStack);
    }
    return new ActionResult<>(EnumActionResult.FAIL, par1ItemStack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 54 with ActionResult

use of net.minecraft.util.ActionResult in project Random-Things by lumien231.

the class ItemRedstoneActivator method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    ItemStack me = playerIn.getHeldItem(handIn);
    int currentDurationIndex = getDurationIndex(me);
    int nextDurationIndex;
    if (playerIn.isSneaking()) {
        nextDurationIndex = currentDurationIndex - 1;
        nextDurationIndex = nextDurationIndex < 0 ? durations.length - 1 : nextDurationIndex;
    } else {
        nextDurationIndex = currentDurationIndex + 1;
        nextDurationIndex = nextDurationIndex >= durations.length ? 0 : nextDurationIndex;
    }
    setDurationIndex(me, nextDurationIndex);
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, me);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack)

Example 55 with ActionResult

use of net.minecraft.util.ActionResult in project Random-Things by lumien231.

the class ItemSpectreKey method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
    ItemStack par1ItemStack = par3EntityPlayer.getHeldItem(hand);
    par3EntityPlayer.setActiveHand(hand);
    return new ActionResult<>(EnumActionResult.SUCCESS, par1ItemStack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ActionResult (net.minecraft.util.ActionResult)148 EnumActionResult (net.minecraft.util.EnumActionResult)147 ItemStack (net.minecraft.item.ItemStack)124 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)39 BlockPos (net.minecraft.util.math.BlockPos)31 RayTraceResult (net.minecraft.util.math.RayTraceResult)25 Nonnull (javax.annotation.Nonnull)15 Vec3d (net.minecraft.util.math.Vec3d)14 IBlockState (net.minecraft.block.state.IBlockState)12 TextComponentString (net.minecraft.util.text.TextComponentString)12 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)11 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 Entity (net.minecraft.entity.Entity)7 Block (net.minecraft.block.Block)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 TileEntity (net.minecraft.tileentity.TileEntity)4 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)3 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)3 FluidStack (net.minecraftforge.fluids.FluidStack)3