Search in sources :

Example 81 with ActionResult

use of net.minecraft.util.ActionResult in project ICBM-Classic by BuiltBrokenModding.

the class ItemAntidote method onItemRightClick.

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

Example 82 with ActionResult

use of net.minecraft.util.ActionResult in project ImmersiveEngineering by BluSunrize.

the class ItemBlockClothDevice method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    if (itemStackIn.getMetadata() != BlockTypes_ClothDevice.BALLOON.getMeta())
        return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
    if (playerIn.isSneaking())
        increaseOffset(itemStackIn);
    else {
        Vec3d pos = playerIn.getPositionVector().addVector(0, playerIn.getEyeHeight(), 0).add(playerIn.getLookVec());
        BlockPos bPos = new BlockPos(pos);
        NBTTagCompound nbt = itemStackIn.getTagCompound();
        int offset = nbt == null ? 0 : nbt.getByte("offset");
        bPos = bPos.up(offset);
        if (worldIn.isAirBlock(bPos)) {
            if (!worldIn.isRemote) {
                worldIn.setBlockState(bPos, IEContent.blockClothDevice.getStateFromMeta(BlockTypes_ClothDevice.BALLOON.getMeta()));
                itemStackIn.stackSize--;
                if (itemStackIn.stackSize <= 0)
                    playerIn.setHeldItem(hand, null);
            }
            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 83 with ActionResult

use of net.minecraft.util.ActionResult in project Railcraft by Railcraft.

the class ItemFilterBeeGenome method onItemRightClick.

@Optional.Method(modid = ForestryPlugin.FORESTRY_ID)
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    NBTTagCompound nbt = InvTools.getItemDataRailcraft(stack, "filter");
    if (nbt != null) {
        try {
            EnumBeeChromosome chromosome = EnumBeeChromosome.SPECIES;
            try {
                chromosome = EnumBeeChromosome.valueOf(nbt.getString("chromosome"));
            } catch (IllegalArgumentException ignored) {
            }
            chromosome = EnumTools.next(chromosome, EnumBeeChromosome.values());
            nbt.setString("chromosome", chromosome.name());
        } catch (Throwable throwable) {
            Game.logErrorAPI(Mod.FORESTRY.modId, throwable, EnumBeeChromosome.class);
        }
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, stack.copy());
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumBeeChromosome(forestry.api.apiculture.EnumBeeChromosome)

Example 84 with ActionResult

use of net.minecraft.util.ActionResult in project RecurrentComplex by Ivorforce.

the class ItemBlockSelectorFloating method onItemRightClick.

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
    ItemStack itemStackIn = playerIn.getHeldItem(hand);
    if (worldIn.isRemote) {
        BlockPos position = getHoveredBlock(playerIn, getSelectionRange(itemStackIn));
        sendClickToServer(itemStackIn, worldIn, playerIn, position);
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 85 with ActionResult

use of net.minecraft.util.ActionResult in project Railcraft by Railcraft.

the class ItemFluidContainer method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    RayTraceResult mop = rayTrace(world, player, false);
    //noinspection ConstantConditions
    if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos pos = mop.getBlockPos();
        if (!world.isBlockModifiable(player, pos))
            return new ActionResult<>(EnumActionResult.FAIL, stack);
        pos = pos.offset(mop.sideHit);
        if (!player.canPlayerEdit(pos, mop.sideHit, stack))
            return new ActionResult<>(EnumActionResult.FAIL, stack);
        if (tryPlaceContainedLiquid(world, pos) && !player.capabilities.isCreativeMode) {
            ItemStack empty = getContainerItem(stack);
            if (InvTools.isEmpty(empty)) {
                empty = stack.copy();
                empty.stackSize = 0;
            }
            return new ActionResult<>(EnumActionResult.SUCCESS, empty);
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) 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