Search in sources :

Example 76 with ActionResult

use of net.minecraft.util.ActionResult in project LogisticsPipes by RS485.

the class ItemHUDArmor method onItemRightClick.

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (MainProxy.isClient(world)) {
        return new ActionResult<>(EnumActionResult.PASS, stack);
    }
    useItem(player, world);
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 77 with ActionResult

use of net.minecraft.util.ActionResult in project LogisticsPipes by RS485.

the class ItemPipeController method onItemRightClick.

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (MainProxy.isClient(world)) {
        return new ActionResult<>(EnumActionResult.PASS, stack);
    }
    useItem(player, world);
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : EnumActionResult(net.minecraft.util.EnumActionResult) ActionResult(net.minecraft.util.ActionResult) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 78 with ActionResult

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

the class ItemSkyhook method onItemRightClick.

/*@Override
	public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
	{
		Multimap multimap = super.getAttributeModifiers(slot, stack);
		if(slot == EntityEquipmentSlot.MAINHAND)
		{
			float dmg = 5 + ItemNBTHelper.getFloat(stack, "fallDamageBoost");
			multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", dmg, 0));
		}
		return multimap;
	}*/
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (player.getCooldownTracker().hasCooldown(this))
        return new ActionResult<>(EnumActionResult.PASS, stack);
    if (player.isSneaking()) {
        boolean limitSpeed = toggleSpeedLimit(stack);
        if (limitSpeed)
            player.sendStatusMessage(new TextComponentTranslation("chat.immersiveengineering.info.skyhookLimited"), true);
        else
            player.sendStatusMessage(new TextComponentTranslation("chat.immersiveengineering.info.skyhookUnlimited"), true);
    } else {
        SkyhookUserData data = player.getCapability(SKYHOOK_USER_DATA, EnumFacing.UP);
        assert data != null;
        if (data.hook != null && !world.isRemote) {
            data.dismount();
            IELogger.logger.info("Player left voluntarily");
        } else {
            data.startHolding();
            player.setActiveHand(hand);
        }
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) SkyhookUserData(blusunrize.immersiveengineering.api.CapabilitySkyhookData.SkyhookUserData) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 79 with ActionResult

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

the class ItemRadarGun method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) {
    if (// also clear the gps coord if the play is shift-rightclicking in the air
    player.isSneaking()) {
        if (!world.isRemote) {
            ItemStack stack = player.getHeldItem(handIn);
            stack.setTagCompound(null);
            stack.setItemDamage(0);
            LanguageUtility.addChatToPlayer(player, "gps.cleared.name");
            player.inventoryContainer.detectAndSendChanges();
        }
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(handIn));
    }
    if (world.isRemote) {
        RayTraceResult objectMouseOver = player.rayTrace(200, 1);
        if (objectMouseOver.typeOfHit != RayTraceResult.Type.MISS) {
            // TODO add message saying that the gps target is out of range.
            final TileEntity tileEntity = world.getTileEntity(objectMouseOver.getBlockPos());
            if (!(ICBMClassicHelpers.isLauncher(tileEntity, null))) {
                ICBMClassic.packetHandler.sendToServer(new PacketPlayerItem(player).addData(objectMouseOver.getBlockPos()));
            }
        }
    }
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(handIn));
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) PacketPlayerItem(icbm.classic.lib.network.packet.PacketPlayerItem)

Example 80 with ActionResult

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

the class ItemRocketLauncher method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
    ItemStack itemstack = player.getHeldItem(handIn);
    long clickMs = System.currentTimeMillis();
    if (clickTimePlayer.containsKey(player.getName())) {
        if (clickMs - clickTimePlayer.get(player.getName()) < firingDelay) {
            // TODO play weapon empty click audio to note the gun is reloading
            return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack);
        }
    }
    player.setActiveHand(handIn);
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
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